Skip to content

Commit 40b256b

Browse files
authored
CI: improve publish workflow (#409)
2 parents 15368ca + 8d2210c commit 40b256b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

.github/workflows/docker-publish.yml

+9-6
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ defaults:
1919

2020
concurrency:
2121
# this expression gives us the name of the deployment environment. It works like a ternary operation (see https://github.com/actions/runner/issues/409#issuecomment-727565588)
22-
group: ${{ !startsWith(github.ref, 'refs/tags/') && github.ref_name || contains(github.ref, '-rc') && 'test' || 'prod' }}
22+
group: ${{ github.ref_type != 'tag' && github.ref_name || contains(github.ref, '-rc') && 'test' || 'prod' }}
2323
cancel-in-progress: true
2424

2525
jobs:
2626
test:
2727
uses: ./.github/workflows/run-tests.yml
28-
if: startsWith(github.ref, 'refs/tags/')
28+
if: github.ref_type == 'tag'
2929

3030
deploy:
3131
needs: test
3232
# !cancelled() is needed because if the whole workflow was cancelled, we don't want this job to run.
33-
# (!startsWith(github.ref, 'refs/tags/') || needs.test.result == 'success') is needed because if `test` did run, we only want this to run if `test` succeeded.
34-
if: (!cancelled() && (!startsWith(github.ref, 'refs/tags/') || needs.test.result == 'success'))
33+
# (github.ref_type != 'tag' || needs.test.result == 'success') is needed because if `test` did run, we only want this to run if `test` succeeded.
34+
if: (!cancelled() && (github.ref_type != 'tag' || needs.test.result == 'success'))
3535
runs-on: ubuntu-latest
36-
environment: ${{ !startsWith(github.ref, 'refs/tags/') && github.ref_name || contains(github.ref, '-rc') && 'test' || 'prod' }}
36+
environment: ${{ github.ref_type != 'tag' && github.ref_name || contains(github.ref, '-rc') && 'test' || 'prod' }}
3737

3838
steps:
3939
- name: Checkout
@@ -63,6 +63,9 @@ jobs:
6363
- name: Write commit SHA to file
6464
run: echo "${{ github.sha }}" >> static/sha.txt
6565

66+
- name: Write version to file
67+
run: echo "${{ github.ref_name }}" >> static/version.txt
68+
6669
- name: Docker Login to GitHub Container Registry
6770
uses: docker/login-action@v3
6871
with:
@@ -85,6 +88,6 @@ jobs:
8588
file: Dockerfile
8689
push: true
8790
tags: |
88-
ghcr.io/${{ github.repository }}:${{ !startsWith(github.ref, 'refs/tags/') && github.ref_name || contains(github.ref, '-rc') && 'test' || 'prod' }}
91+
ghcr.io/${{ github.repository }}:${{ github.ref_type != 'tag' && github.ref_name || contains(github.ref, '-rc') && 'test' || 'prod' }}
8992
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
9093
ghcr.io/${{ github.repository }}:${{ github.sha }}

0 commit comments

Comments
 (0)