Skip to content

Commit 5ca783e

Browse files
committed
Merge branch 'gh-workflow-update' into 'main'
feat: update github workflow See merge request flarenetwork/flare-system-c-chain-indexer!50
2 parents bdf5c85 + 52ec9db commit 5ca783e

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

.github/workflows/build-docker.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,32 @@ jobs:
1818
- uses: docker/setup-qemu-action@v3
1919
- uses: docker/setup-buildx-action@v3
2020

21-
- run: echo "IMAGE_TAG=latest" >> $GITHUB_ENV
22-
if: github.ref_name == 'main'
23-
- run: echo "IMAGE_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
24-
if: startsWith(github.ref, 'refs/tags/v')
21+
- name: Set ALL_TAGS
22+
env:
23+
REPOSITORY: '${{ github.repository }}'
24+
run: |
25+
# tag main if main branch
26+
if [[ "${{ github.ref_name }}" == "main" ]]; then
27+
image_tags=("main")
28+
# tag with tag name if tag
29+
elif [[ "${{ github.ref }}" == refs/tags/v* ]]; then
30+
image_tags=("${{ github.ref_name }}")
31+
# tag with latest if tag is a new major, minor or patch version
32+
if [[ "${{ github.ref_name}}" =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
33+
image_tags+=("latest")
34+
fi
35+
fi
36+
37+
lc_repo=${REPOSITORY,,}
38+
39+
image_paths=()
40+
for tag in ${image_tags[@]}; do
41+
image_paths+=("ghcr.io/$lc_repo:$tag")
42+
done
43+
44+
# join with ',' and then skip first character
45+
ALL_TAGS=$(printf ',%s' "${image_paths[@]}")
46+
echo "ALL_TAGS=${ALL_TAGS:1}" >>$GITHUB_ENV
2547
2648
- name: Login to ghcr.io
2749
uses: docker/login-action@v3
@@ -36,5 +58,4 @@ jobs:
3658
context: . # Because GH actions are for kids and put protection on everything; https://stackoverflow.com/a/71159809/11276254
3759
platforms: linux/amd64,linux/arm64
3860
push: true
39-
tags: |
40-
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
61+
tags: ${{ env.ALL_TAGS }}

0 commit comments

Comments
 (0)