Skip to content

Use GITHUB_OUTPUT instead of GITHUB_ENV #16

Use GITHUB_OUTPUT instead of GITHUB_ENV

Use GITHUB_OUTPUT instead of GITHUB_ENV #16

Workflow file for this run

name: 'Build and Publish Bundle'
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-alpha[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-beta[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+'
env:
CONTROLLER_IMAGE_NAME: simple-demo-operator
BUNDLE_IMAGE_NAME: simple-demo-operator-bundle
OPERATOR_SDK_VERSION: v1.32.0
jobs:
tag-controller-for-release:
runs-on: ubuntu-latest
outputs:
vprefixed-release-tag: ${{ steps.set-env-tags.outputs.VPREFIXED_RELEASE_TAG }}
release-tag: ${{ steps.set-env-tags.outputs.RELEASE_TAG }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Env Tags
id: set-env-tags
run: |
echo VPREFIXED_RELEASE_TAG=$(echo $GITHUB_REF | cut -d '/' -f 3) | tee -a $GITHUB_OUTPUT
echo RELEASE_TAG=$(echo $GITHUB_REF | cut -d '/' -f 3 | sed -e 's/^v//g') | tee -a $GITHUB_OUTPUT
- name: Log in to Quay.io
uses: redhat-actions/podman-login@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
registry: quay.io
# The controller should already exists at a tag matching the commit hash.
# Apply the release tag to this controller.
- name: Apply a release tag to existing controller image.
run: |
skopeo copy --all docker://quay.io/${{ secrets.IMAGE_REPOSITORY }}/${{ env.CONTROLLER_IMAGE_NAME }}:${{ github.sha }} docker://quay.io/${{ secrets.IMAGE_REPOSITORY }}/${{ env.CONTROLLER_IMAGE_NAME }}:${{ steps.set-env-tags.outputs.RELEASE_TAG }}
pin-images-and-bundle:
needs: [tag-controller-for-release]
runs-on: ubuntu-latest
env:
VPREFIXED_RELEASE_TAG: ${{ needs.tag-controller-for-release.outputs.vprefixed-release-tag }}
RELEASE_TAG: ${{ needs.tag-controller-for-release.outputs.release-tag }}
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- name: Log in to Quay.io
uses: redhat-actions/podman-login@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
registry: quay.io
- name: Install OperatorSDK
run: |
wget -O /usr/local/bin/operator-sdk https://github.com/operator-framework/operator-sdk/releases/download/${{ env.OPERATOR_SDK_VERSION }}/operator-sdk_linux_amd64
chmod +x /usr/local/bin/operator-sdk
operator-sdk --version
/usr/local/bin/operator-sdk --version
- name: Regenerate bundle with pinned images
run: USE_IMAGE_DIGESTS=true make bundle
- name: Ensure bundle validates after CI modifications
run: |
operator-sdk bundle validate ./bundle
- name: Build bundle image
id: build-bundle-images
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.BUNDLE_IMAGE_NAME }}
tags: ${{ env.VPREFIXED_RELEASE_TAG }} # Note: "vX.Y.Z" prefixed
containerfiles: |
./bundle.Dockerfile
- name: Push to target push registry.
id: push-bundle-img-to-registry
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ env.BUNDLE_IMAGE_NAME }}
tags: ${{ env.VPREFIXED_RELEASE_TAG }} # Note: "vX.Y.Z" prefixed!
registry: quay.io/${{ secrets.IMAGE_REPOSITORY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}