I have the following action that first runs a semantic release and then builds a docker image. At the moment the image is tagged with master
but I want it to be tagged with the release i.e. v1.0.8
I assumed that ${{ github.ref_name }}
would refer to the release number that was created in the previous step rather than the branch name.
Is there a different variable I need to be using?
name: Release
on:
push:
branches: [ master ]
jobs:
release:
permissions:
contents: write
issues: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 18
- run: npm ci
- run: npm run build
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile --tag gitflow-test-gui:${{ github.ref_name }}
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push the latest Docker image
uses: docker/build-push-action@v2
with:
push: true
tags: ghcr.io/ioncoder/gitflow-test-gui:latest
- name: Push the Docker image with the release tag
uses: docker/build-push-action@v2
with:
push: true
tags: ghcr.io/ioncoder/gitflow-test-gui:${{ github.ref_name}}