From 5e7e3e1f753435d17b0983f1dfe0bc2a29a260a8 Mon Sep 17 00:00:00 2001 From: corverroos Date: Wed, 6 Apr 2022 15:47:37 +0200 Subject: [PATCH] github/workflows: fix docker tags (#375) Fixes "build" github action to: - Push "latest" tag on commits to main. - Push "git short sha" tag on commits to main. - Push "git tag" tag on tag pushes category: bug ticket: #339 --- .github/workflows/build.yml | 23 ++++++++++++----------- .github/workflows/release.yml | 28 ---------------------------- 2 files changed, 12 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ea4f6dab5..734a295a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,8 @@ on: push: branches: - main - + tags: + - 'v*' name: Build docker image jobs: build-docker: @@ -13,17 +14,19 @@ jobs: - uses: docker/setup-buildx-action@v1 - - id: get-version - run: | - version=$(echo "${{ github.sha }}" | cut -c1-8) - echo "::set-output name=version::$version" - - id: meta uses: docker/metadata-action@v3 with: - images: | - ghcr.io/obolnetwork/charon/charon - tags: "latest,${{steps.get-version.outputs.version}}" + images: ghcr.io/obolnetwork/charon/charon + tags: | + # Tag "git short sha" on push to branch (main) + type=sha,event=branch + + # Tag "latest" on all events + type=raw,value=latest + + # Tag "tag ref" on tag push events + type=ref,event=tag - uses: docker/login-action@v1 with: @@ -38,5 +41,3 @@ jobs: push: true build-args: GITHUB_SHA=${{ github.sha }} tags: ${{ steps.meta.outputs.tags }} - - - run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9cabe68e7..7de6ecf97 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,34 +10,6 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: docker/setup-buildx-action@v1 - - - id: get-tag - run: | - tag=$(echo "${{ github.ref }}" | cut -d / -f 3) - echo "::set-output name=tag::$tag" - - - id: meta - uses: docker/metadata-action@v3 - with: - images: | - ghcr.io/obolnetwork/charon/charon - tags: "${{steps.get-tag.outputs.tag}}" - - - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.CONTAINER_REGISTRY_SECRET }} - - - uses: docker/build-push-action@v2 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - build-args: GITHUB_SHA=${{ github.sha }} - tags: ${{ steps.meta.outputs.tags }} - - run: docker run ghcr.io/obolnetwork/charon/charon:${{steps.get-tag.outputs.tag}} charon run --help > cli-reference.txt - run: cat cli-reference.txt