Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
ref: ${{ github.event.workflow_run.head_sha || github.sha }}

- name: Install python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -63,19 +63,27 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get git branch and short sha for tag
env:
EVENT_BRANCH: ${{ github.event.workflow_run.head_branch || github.ref_name }}
EVENT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
Comment thread
toby-coleman marked this conversation as resolved.
run: |
git_hash_short=$(git rev-parse --short "$GITHUB_SHA")
echo "GIT_HASH_SHORT=${git_hash_short}" >> $GITHUB_ENV
git_branch=$(git branch -r --contains ${{ github.ref }} --merged ${{ github.ref }} --format "%(refname:lstrip=3)" | grep -v HEAD)
echo "GIT_BRANCH=${git_branch}" >> $GITHUB_ENV
git_branch_docker_safe=$(echo ${git_branch} | tr / -)
echo "GIT_BRANCH_DOCKER_SAFE=${git_branch_docker_safe}" >> $GITHUB_ENV
git_hash_short=$(git rev-parse --short "$EVENT_SHA")
printf 'GIT_HASH_SHORT=%s\n' "${git_hash_short}" >> "$GITHUB_ENV"
git_branch="$EVENT_BRANCH"
if [[ -z "${git_branch}" ]]; then
git_branch=$(git rev-parse --abbrev-ref HEAD)
fi
printf 'GIT_BRANCH=%s\n' "${git_branch}" >> "$GITHUB_ENV"
Comment thread
toby-coleman marked this conversation as resolved.
git_branch_docker_safe=$(echo "${git_branch}" | tr / -)
printf 'GIT_BRANCH_DOCKER_SAFE=%s\n' "${git_branch_docker_safe}" >> "$GITHUB_ENV"

# Tagging documented at: https://github.com/docker/metadata-action?tab=readme-ov-file#basic
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
# Match SHA tags and revision labels to the commit checked out above.
context: git
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}},value=${{ env.PACKAGE_VERSION }},enable=${{ (github.event_name == 'workflow_run') && (github.event.workflow_run.conclusion == 'success') }}
Expand Down
Loading