From 64edca2a65d36014453e88e02b4d45df0565f842 Mon Sep 17 00:00:00 2001 From: Balazs Nadasdi Date: Tue, 15 Nov 2022 09:27:46 +0100 Subject: [PATCH 1/2] feat: build and push docker image to ghcr --- .github/workflows/ghcr.yaml | 39 +++++++++++++++++++++++++++++++++++++ Dockerfile | 1 + 2 files changed, 40 insertions(+) create mode 100644 .github/workflows/ghcr.yaml diff --git a/.github/workflows/ghcr.yaml b/.github/workflows/ghcr.yaml new file mode 100644 index 0000000..a0acca9 --- /dev/null +++ b/.github/workflows/ghcr.yaml @@ -0,0 +1,39 @@ +name: Build and publish a Docker image to ghcr.io +on: + push: + tags: [ "v*.*.*" ] + branches: [ "build-automation" ] + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: "ubuntu-latest" + + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v3 + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 8f9cca1..35f4c38 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,7 @@ RUN go mod download COPY main.go main.go COPY api/ api/ COPY controllers/ controllers/ +COPY pkg/ pkg/ # Build # the GOARCH has not a default value to allow the binary be built according to the host where the command From 544788a91eb770d6104ddb4335c576a08c009f33 Mon Sep 17 00:00:00 2001 From: Balazs Nadasdi Date: Tue, 15 Nov 2022 09:28:17 +0100 Subject: [PATCH 2/2] remove this branch from build target --- .github/workflows/ghcr.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ghcr.yaml b/.github/workflows/ghcr.yaml index a0acca9..4e3d72d 100644 --- a/.github/workflows/ghcr.yaml +++ b/.github/workflows/ghcr.yaml @@ -2,7 +2,6 @@ name: Build and publish a Docker image to ghcr.io on: push: tags: [ "v*.*.*" ] - branches: [ "build-automation" ] workflow_dispatch: env: