Skip to content

Commit

Permalink
github/workflows: fix docker tags (#375)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
corverroos committed Apr 6, 2022
1 parent 671368f commit 5e7e3e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 39 deletions.
23 changes: 12 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ on:
push:
branches:
- main

tags:
- 'v*'
name: Build docker image
jobs:
build-docker:
Expand All @@ -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:
Expand All @@ -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 }}
28 changes: 0 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5e7e3e1

Please sign in to comment.