Skip to content

Commit

Permalink
Update GitHub Actions workflow to set VERSION to 'master' when the gi…
Browse files Browse the repository at this point in the history
…thub.head_ref is 'master'.

This prevents attempting to extract a version from the branch name when on the master branch, ensuring the Docker image is tagged correctly.
  • Loading branch information
mjanez committed Sep 24, 2024
1 parent 3a83875 commit d8f5bbe
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ name: Build and push ckan-docker image from PR Merge
on:
pull_request:
types:
- closed
- closed
branches:
- master
- 'ckan-*.*.*'
- '!dev/ckan-*.*.*'
- '!feature/*'
- '!fix/*'
- master
- 'ckan-*.*.*'
- '!dev/ckan-*.*.*'
- '!feature/*'
- '!fix/*'

env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -45,7 +45,12 @@ jobs:

- name: Extract tag version from branch name
id: extract_tag_version
run: echo "VERSION=$(echo ${{ github.head_ref }} | sed 's/^ckan-//')" >> $GITHUB_ENV
run: |
if [ "${{ github.head_ref }}" = "master" ]; then
echo "VERSION=master" >> $GITHUB_ENV
else
echo "VERSION=$(echo ${{ github.head_ref }} | sed 's/^ckan-//')" >> $GITHUB_ENV
fi
- name: Extract Docker metadata
id: meta
Expand Down Expand Up @@ -81,7 +86,7 @@ jobs:
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
format: sarif
output: trivy-results.sarif

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
Expand Down

0 comments on commit d8f5bbe

Please sign in to comment.