Skip to content

Commit

Permalink
Move container images creation to release workflow
Browse files Browse the repository at this point in the history
This makes it possible to retrigger the entire release process,
including all assets creation, by retagging the main branch.

Starting with this commit, build triggers on the
quay.io/redhat-certification/chart-verifier repo are no longer needed.

close #383
  • Loading branch information
mgoerens committed Jul 26, 2023
1 parent 32f56da commit a96ed22
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 38 deletions.
38 changes: 1 addition & 37 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build, Test, Automerge and Tag
# This workflow runs on all PRs that are targetting the main branch.
#
# It runs the test suite. If the PR is a release PR, it automerges and tags the main branch with
# the corresonding new version. Finally, it retags the container image with latest.
# the corresonding new version.

on:
pull_request_target:
Expand Down Expand Up @@ -227,39 +227,3 @@ jobs:
custom_tag: ${{ steps.check_version_in_PR.outputs.PR_version }}
tag_prefix: ""
commit_sha: ${{ steps.master_sha.outputs.origin_master_sha }}

- name: Wait for image build to complete
# Quay is configured to automatically build our image. This waits
# for it to complete before proceeding successfully.
id: wait_for_image_build
if: ${{ steps.check_version_updated.outputs.updated == 'true'}}
run: |
expectedImage=quay.io/redhat-certification/chart-verifier:${{ steps.check_version_in_PR.outputs.PR_version }}
for i in {1..30}; do
s=60
echo "Querying Quay for "${expectedImage}" in ${s} seconds..."
sleep $s
skopeo inspect docker://"${expectedImage}" && echo "Image Found!" && exit 0
done
echo "ERR Image not found in allotted time."
exit 1
- name: Login to Quay as Bot
id: login_as_bot
if: ${{ steps.wait_for_image_build.outcome == 'success'}}
uses: redhat-actions/podman-login@v1
with:
username: ${{ secrets.QUAY_BOT_USERNAME }}
password: ${{ secrets.QUAY_BOT_TOKEN }}
registry: quay.io/redhat-certification

- name: Update latest tag
if: ${{ steps.login_as_bot.outcome == 'success'}}
id: update_latest_tag
# TODO: When we shift to a push-from-this-repo model (instead of Quay build model)
# we should transition this tag workflow to use the digest of the image built here in CI.
run: |
imageReference=quay.io/redhat-certification/chart-verifier
podman pull ${imageReference}:${{ steps.check_version_in_PR.outputs.PR_version }}
podman tag ${imageReference}:${{ steps.check_version_in_PR.outputs.PR_version }} ${imageReference}:latest
podman push ${imageReference}:latest
25 changes: 24 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ name: create release on new tags
# Finally, as mentioned above, create a new tag (e.g. `git tag 1.12.2 && git push --tags`) to
# recreate the release.
#
# This workflow builds the tarball, creates the Github release and attaches the tarball to it.
# This workflow builds all release assets (the tarball and the container images), creates the
# Github release and attaches the tarball to it.

on:
push:
Expand Down Expand Up @@ -88,3 +89,25 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build container images
id: build_container_images
run: |
# Build podman images locally
image_tag=${{ steps.get_tag.outputs.release_version }}
podman build \
-t quay.io/redhat-certification/chart-verifier:$image_tag \
-t quay.io/redhat-certification/chart-verifier:latest \
-t quay.io/redhat-certification/chart-verifier:main .
- name: Push to quay.io
id: push_to_quay
uses: redhat-actions/push-to-registry@v2
with:
image: chart-verifier
tags: |
${{ steps.get_tag.outputs.release_version }}
latest
main
registry: quay.io/redhat-certification
username: ${{ secrets.QUAY_BOT_USERNAME }}
password: ${{ secrets.QUAY_BOT_TOKEN }}

0 comments on commit a96ed22

Please sign in to comment.