From 925f4c3f5a5f2289e593177cdd44a8f010e46c9a Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Sat, 2 Sep 2023 14:03:39 +0200 Subject: [PATCH] Change Github workflow to deploy docker image --- .github/workflows/go-deploy.yml | 34 +++++++++++++++++++++++++++++++++ .github/workflows/go-test.yml | 17 ----------------- Dockerfile | 4 ++++ 3 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/go-deploy.yml delete mode 100644 .github/workflows/go-test.yml diff --git a/.github/workflows/go-deploy.yml b/.github/workflows/go-deploy.yml new file mode 100644 index 0000000..1fee636 --- /dev/null +++ b/.github/workflows/go-deploy.yml @@ -0,0 +1,34 @@ +name: Deploy + +on: + push: + branches: [ "master", "main" ] + pull_request: + branches: [ "master", "main" ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-go@v3 + with: + go-version: '1.20' + + - run: go test + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to ghcr.io + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Execute image build and push + run: | + docker build -t ghcr.io/pcvolkmer/idicon . + docker push ghcr.io/pcvolkmer/idicon \ No newline at end of file diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml deleted file mode 100644 index 2583c52..0000000 --- a/.github/workflows/go-test.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Go test - -on: - push: - branches: [ "master", "main" ] - pull_request: - branches: [ "master", "main" ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: '1.20' - - run: go test \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 04d5d95..61046ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,6 +21,10 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app -ldflags '-w -s' FROM scratch +LABEL org.opencontainers.image.source = "https://github.com/pcvolkmer/idicon" +LABEL org.opencontainers.image.licenses = "MIT" +LABEL org.opencontainers.image.description = "Simple identicon service" + COPY --from=build-env /etc/passwd /etc/passwd COPY --from=build-env /etc/group /etc/group COPY --from=build-env /tmp/build/app /idicon