Skip to content
Draft
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
20 changes: 13 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,13 +63,19 @@ 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 }}
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"
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
Expand Down
Loading