diff --git a/.github/actions/get-tag-name/action.yml b/.github/actions/get-tag-name/action.yml index 46acce582..ad50f8cfc 100644 --- a/.github/actions/get-tag-name/action.yml +++ b/.github/actions/get-tag-name/action.yml @@ -14,7 +14,9 @@ runs: run: | BUILD_NUMBER="$(git rev-list --count HEAD)" SHORT_HASH="$(git rev-parse --short=7 HEAD)" - if [[ "${{ env.BRANCH_NAME }}" == "master" || "${{ env.BRANCH_NAME }}" == "b${BUILD_NUMBER}" ]]; then + if [[ "$GITHUB_REF_TYPE" == "tag" && "${{ env.BRANCH_NAME }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "name=${{ env.BRANCH_NAME }}" >> $GITHUB_OUTPUT + elif [[ "${{ env.BRANCH_NAME }}" == "master" || "${{ env.BRANCH_NAME }}" == "b${BUILD_NUMBER}" ]]; then echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT else SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ad1a9de9a..778e7b062 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -16,6 +16,10 @@ on: description: "Skip the s390x build target (useful for fast test runs that do not need the IBM Z runner)" type: boolean default: false + skip_ref_check: + description: "Skip the requirement to run from a tag (allows branch refs)" + type: boolean + default: false schedule: # Rebuild daily rather than on every push because it is expensive - cron: '12 4 * * *' @@ -38,6 +42,14 @@ jobs: source_tag: ${{ steps.srctag.outputs.name }} steps: + - name: Check manual run ref + if: ${{ github.event_name == 'workflow_dispatch' && !inputs.skip_ref_check }} + run: | + if [[ "$GITHUB_REF_TYPE" != "tag" ]]; then + echo "::error::Manual runs of this workflow must be started from a tag" + exit 1 + fi + - name: Clone id: checkout uses: actions/checkout@v6