Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: leverage retry-action in build step as well #506

Closed
wants to merge 4 commits into from
Closed
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
82 changes: 59 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,27 +174,63 @@ jobs:
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/main/README.md
io.artifacthub.package.logo-url=https://avatars.githubusercontent.com/u/120078124?s=200&v=4

# Workaround to fix indentation for the labels so that retries work.
- name: Left pad labels
id: left_pad_labels
shell: bash
env:
LABELS: ${{steps.meta.outputs.labels}}
run: |
echo "Labels:"
echo "${LABELS}"
export TRANSFORMED=$(echo "$LABELS" | sed 's,^, ,g')
echo "Transformed:"
echo "${TRANSFORMED}"
echo "LABELS<<EOF" >> $GITHUB_ENV
echo "$TRANSFORMED" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

# Build image using Buildah action
- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2
uses: Wandalen/[email protected]
with:
containerfiles: |
./Containerfile
image: ${{ env.IMAGE_NAME }}
tags: |
${{ steps.generate-tags.outputs.alias_tags }}
build-args: |
IMAGE_NAME=${{ matrix.image_name }}
SOURCE_ORG=${{ env.SOURCE_ORG }}
SOURCE_IMAGE=${{ env.SOURCE_IMAGE }}
FEDORA_MAJOR_VERSION=${{ matrix.major_version }}
RPMFUSION_MIRROR=${{ vars.RPMFUSION_MIRROR }}
labels: ${{ steps.meta.outputs.labels }}
oci: false
extra-args: |
--target=${{ matrix.build_target }}
action: redhat-actions/buildah-build@v2
attempt_limit: 3
attempt_delay: 2000
with: |
containerfiles: |
./Containerfile
image: |
${{ env.IMAGE_NAME }}
tags: |
${{ steps.generate-tags.outputs.alias_tags }}
build-args: |
IMAGE_NAME=${{ matrix.image_name }}
SOURCE_ORG=${{ env.SOURCE_ORG }}
SOURCE_IMAGE=${{ env.SOURCE_IMAGE }}
FEDORA_MAJOR_VERSION=${{ matrix.major_version }}
RPMFUSION_MIRROR=${{ vars.RPMFUSION_MIRROR }}
oci: |
false
extra-args: |
--target=${{ matrix.build_target }}
labels: |
${{ env.LABELS }}

# These are for troubleshooting only and are not strictly needed.
- name: Echo outputs of image build
if: github.event_name != 'pull_request'
run: |
echo "${{ toJSON(steps.build_image.outputs) }}"

- name: Show parsed outputs of image build
if: github.event_name != 'pull_request'
run: |
echo "${{ steps.build_image.outputs.outputs && fromJSON(steps.build_image.outputs.outputs).image }}"
echo "${{ steps.build_image.outputs.outputs && fromJSON(steps.build_image.outputs.outputs).tags }}"
echo "${{ steps.build_image.outputs.outputs && fromJSON(steps.build_image.outputs.outputs).image-with-tag }}"

# Workaround bug where capital letters in your GitHub username make it impossible to push to GHCR.
# https://github.com/macbre/push-to-ghcr/issues/12
- name: Lowercase Registry
Expand All @@ -215,14 +251,19 @@ jobs:
attempt_limit: 3
attempt_delay: 15000
with: |
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
image: ${{ steps.build_image.outputs.outputs && fromJSON(steps.build_image.outputs.outputs).image }}
tags: ${{ steps.build_image.outputs.outputs && fromJSON(steps.build_image.outputs.outputs).tags }}
registry: ${{ steps.registry_case.outputs.lowercase }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
extra-args: |
--disable-content-trust

- name: Echo outputs of push to GHCR
if: github.event_name != 'pull_request'
run: |
echo "${{ steps.push.outputs.outputs && toJSON(steps.push.outputs) }}"

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
Expand All @@ -244,11 +285,6 @@ jobs:
COSIGN_EXPERIMENTAL: false
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }}

- name: Echo outputs
if: github.event_name != 'pull_request'
run: |
echo "${{ toJSON(steps.push.outputs) }}"

check:
name: Check all builds successful
if: ${{ !cancelled() }}
Expand Down