ci: updates publish.yml image releasing process #60
Workflow file for this run
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
name: Publish Image to Quay | |
on: | |
schedule: | |
- 0 0 */30 * * | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "Name of the tag for the published image" | |
type: string | |
required: true | |
skip_tests: | |
description: "Skip end to end tests when publishing an image." | |
type: boolean | |
required: false | |
default: false | |
no_cache: | |
description: "Skip using cache when building the image." | |
type: boolean | |
required: false | |
default: false | |
env: | |
IMAGE_NAME: trestle-bot | |
IMAGE_REGISTRY: quay.io | |
jobs: | |
publish-image: | |
runs-on: 'ubuntu-latest' | |
permissions: | |
contents: read | |
# kics-scan ignore-line | |
id-token: write # needed for signing the images with GitHub OIDC Token | |
outputs: | |
skip_tests: ${{ steps.check_event.outputs.event_type == 'release' || | |
(steps.check_event.outputs.event_type == 'workflow_dispatch' && | |
github.event.inputs.skip_tests == 'true') }} | |
image: ${{ steps.build_publis_image.outputs.image_sha }} | |
steps: | |
- name: Login to Quay | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.QUAY_USER }} | |
password: ${{ secrets.QUAY_TOKEN }} | |
registry: ${{ env.IMAGE_REGISTRY }} | |
- name: Check if triggered by release or workflow dispatch | |
id: check_event | |
run: echo "event_type=${{ toJson(github.event_name) }}" >> "$GITHUB_OUTPUT" | |
# Using intermediary variable to process event based input | |
- name: Set environment information for release | |
if: ${{ steps.check_event.outputs.event_type == 'release' }} | |
run: | | |
echo "TAG=$RELEASE_VERSION" >> "$GITHUB_ENV" | |
echo "NO_CACHE=true" >> "$GITHUB_ENV" | |
env: | |
RELEASE_VERSION: ${{ github.event.release.tag_name }} | |
- name: Set environment information for workflow dispatch | |
if: ${{ steps.check_event.outputs.event_type == 'workflow_dispatch' }} | |
run: | | |
echo "TAG=$INPUT_VERSION" >> "$GITHUB_ENV" | |
echo "NO_CACHE=true" >> "$GITHUB_ENV" | |
env: | |
INPUT_VERSION: ${{ github.event.inputs.tag }} | |
INPUT_NO_CACHE: ${{ github.event.inputs.no_cache }} | |
- name: Set environment information for schedule | |
if: ${{ steps.check_event.outputs.event_type == 'workflow_dispatch' }} | |
run: | | |
LATEST_VERSION=$( gh release view --json tagName --jq '.["tagName"]' ) | |
echo "TAG=$LATEST_VERSION" >> "$GITHUB_ENV" | |
echo "NO_CACHE=$INPUT_NO_CACHE" >> "$GITHUB_ENV" | |
- name: Build and Publish the image | |
uses: ./.github/actions/publish-image | |
id: build_publish_image | |
with: | |
image: ${{ env.IMAGE_REGISTRY }}/${{ vars.QUAY_ORG }}/${{ env.IMAGE_NAME }} | |
release_version: ${{ env.TAG }} | |
no-cache: ${{ env.NO_CACHE }} | |
test: | |
permissions: | |
contents: read | |
needs: publish-image | |
if: ${{ needs.publish-image.outputs.skip_tests != 'true' }} | |
uses: ./.github/workflows/e2e.yml | |
with: | |
image: ${{ needs.publish-image.outputs.image }} |