forked from konveyor/tackle2-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Test image build on Dockerfile change
Signed-off-by: Scott J Dickerson <[email protected]>
- Loading branch information
Showing
2 changed files
with
97 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: CI (test image build for a PR with a Dockerfile change) | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- "main" | ||
- "release-*" | ||
|
||
jobs: | ||
checks: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
run-test-image-build: ${{ steps.dockerChanged.outputs.flag }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Check if the `Dockerfile` has been changed by a PR | ||
id: dockerChanged | ||
env: | ||
IS_PR: ${{ !!github.event.pull_request }} | ||
PR: ${{ github.event.pull_request }} | ||
run: | | ||
cat >> "$GITHUB_STEP_SUMMARY" <<EOF | ||
\`\`\`json | ||
$(echo $PR | jq '.') | ||
\`\`\` | ||
EOF | ||
cat >> "$GITHUB_STEP_SUMMARY" <<EOF | ||
\`\`\`sh | ||
> git show --raw HEAD | ||
$(git show --raw HEAD) | ||
\`\`\` | ||
EOF | ||
INCLUDES_DOCKERFILE=$( | ||
if [[ $(git show --raw --oneline HEAD -- Dockerfile | wc --lines) -eq 0 ]]; then | ||
echo "false" | ||
else | ||
echo "true" | ||
fi | ||
) | ||
TEST_IMAGE_BUILD=$( | ||
if [[ $IS_PR == true ]] && [[ $INCLUDES_DOCKERFILE == true ]]; then | ||
echo "true" | ||
else | ||
echo "false" | ||
fi | ||
) | ||
cat >> "$GITHUB_STEP_SUMMARY" <<EOF | ||
PR triggered? \`$IS_PR\` | ||
HEAD commit include a Dockerfile change? \`$INCLUDES_DOCKERFILE\` | ||
Should the image build be tested? \`$TEST_IMAGE_BUILD\` | ||
EOF | ||
echo "flag=$TEST_IMAGE_BUILD" >> "$GITHUB_OUTPUT" | ||
# | ||
# Based on: | ||
# - image-build.yaml | ||
# - konveyor/release-tools/.github/workflows/build-push-images.yaml@main | ||
# | ||
# Only test the image build, no push to quay is required. | ||
# | ||
test-image-build: | ||
runs-on: ubuntu-latest | ||
needs: checks | ||
if: ${{ needs.checks.outputs.run-test-image-build == true }} | ||
|
||
strategy: | ||
fail-fast: true | ||
matrix: | ||
architecture: | ||
- amd64 | ||
- arm64 | ||
|
||
steps: | ||
- name: Checkout merge commit for PR${{ github.event.pull_request.number }} | ||
uses: actions/checkout@v4 | ||
|
||
- name: Test build image on ${{ matrix.architecture }} | ||
id: test-build | ||
uses: redhat-actions/buildah-build@main | ||
with: | ||
image: "tackle2-ui" | ||
tags: PR${{ github.event.pull_request.number }}-${{ matrix.architecture }} | ||
extra-args: "--no-cache --rm --ulimit nofile=4096:4096" | ||
archs: ${{ matrix.architecture }} | ||
labels: "" | ||
containerfiles: "./Dockerfile" | ||
context: "." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters