Skip to content

Commit

Permalink
fix: Improve separation of tags between PR builds and normal builds (#39
Browse files Browse the repository at this point in the history
)
  • Loading branch information
joshua-stone authored Feb 16, 2023
1 parent 24be3ba commit 18ae5e9
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,52 +56,59 @@ jobs:
id: generate-tags
shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
container_tags=()
# The following is run when the timer is triggered or a merge/push to main
# Generate a timestamp for creating an image version history
TIMESTAMP="$(date +%Y%m%d)"
VARIANT="${{ matrix.major_version }}-${{ matrix.driver_version }}"
COMMIT_TAGS=()
BUILD_TAGS=()
container_tags+=("${{ matrix.major_version }}-${{ matrix.driver_version }}")
# Have tags for tracking builds during pull request
SHA_SHORT="$(git rev-parse --short HEAD)"
COMMIT_TAGS+=("pr-${{ github.event.number }}-${VARIANT}")
COMMIT_TAGS+=("${SHA_SHORT}-${VARIANT}")
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
BRANCH="stable"
elif [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[[ "${{ matrix.is_stable_version }}" != "true" ]]; then
BRANCH="unstable"
else
BRANCH="oldstable"
[[ "${{ matrix.is_stable_version }}" == "true" ]] && \
[[ "${{ matrix.is_latest_driver }}" == "true" ]]; then
COMMIT_TAGS+=("pr-${{ github.event.number }}")
COMMIT_TAGS+=("${SHA_SHORT}")
fi
BUILD_TAGS=("${VARIANT}")
if [[ "${{ matrix.is_latest_driver }}" == "true" ]]; then
container_tags+=("${{ matrix.major_version }}-current")
container_tags+=("${BRANCH}")
container_tags+=("${{ matrix.major_version }}")
BUILD_TAGS+=("${{ matrix.major_version }}-current")
BUILD_TAGS+=("${{ matrix.major_version }}")
fi
# Append matching timestamp tags to keep a version history
for TAG in "${container_tags[@]}"; do
container_tags+=("${TAG}-${TIMESTAMP}")
for TAG in "${BUILD_TAGS[@]}"; do
BUILD_TAGS+=("${TAG}-${TIMESTAMP}")
done
if [[ "${BRANCH}" == "stable" ]] && \
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[[ "${{ matrix.is_stable_version }}" == "true" ]] && \
[[ "${{ matrix.is_latest_driver }}" == "true" ]]; then
container_tags+=("${TIMESTAMP}")
container_tags+=("latest")
BUILD_TAGS+=("${TIMESTAMP}")
BUILD_TAGS+=("latest")
fi
echo "Generated the following tags: "
for TAG in "${container_tags[@]}"; do
echo "${TAG}"
done
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
alias_tags=("pr-${{ github.event.number }}")
echo "Generated the following commit tags: "
for TAG in "${COMMIT_TAGS[@]}"; do
echo "${TAG}"
done
alias_tags=("${COMMIT_TAGS[@]}")
else
alias_tags=("${container_tags[@]}")
alias_tags=("${BUILD_TAGS[@]}")
fi
echo "Generated the following build tags: "
for TAG in "${BUILD_TAGS[@]}"; do
echo "${TAG}"
done
echo "alias_tags=${alias_tags[*]}" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -137,7 +144,6 @@ jobs:
image: ${{ format('{0}-nvidia', matrix.image_name) }}
tags: |
${{ steps.generate-tags.outputs.alias_tags }}
${{ steps.generate-tags.outputs.sha_short }}
build-args: |
IMAGE_NAME=${{ matrix.image_name }}
FEDORA_MAJOR_VERSION=${{ matrix.major_version }}
Expand Down

0 comments on commit 18ae5e9

Please sign in to comment.