Skip to content

Publish Image to Quay #21

Publish Image to Quay

Publish Image to Quay #21

Workflow file for this run

name: Publish Image to Quay
on:
schedule:
- cron: 0 0 */30 * *
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: |
Name of the tag for the published image. Will be published as <tag>-<branch>-<sha>.
If a valid semver, associated semver tags will be published as well.
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: complyscribe
IMAGE_REGISTRY: quay.io
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}-publish
cancel-in-progress: true
jobs:
publish-image:
runs-on: 'ubuntu-24.04'
permissions:
contents: read
# kics-scan ignore-line
id-token: write # needed for signing the images with GitHub OIDC Token
steps:
- name: Login to Quay
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}
registry: ${{ env.IMAGE_REGISTRY }}
- name: Set up cosign
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
- 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"
echo "NO_CACHE=true"
echo "BUILD_GIT_REF=$RELEASE_VERSION"
echo "SKIP_TESTS=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"
echo "NO_CACHE=$INPUT_NO_CACHE"
echo "BUILD_GIT_REF=${{ github.ref }}"
echo "SKIP_TESTS=$INPUT_SKIP_TESTS"
} >> "$GITHUB_ENV"
env:
INPUT_VERSION: ${{ github.event.inputs.tag }}
INPUT_NO_CACHE: ${{ github.event.inputs.no_cache }}
INPUT_SKIP_TESTS: ${{ github.event.inputs.skip_tests }}
- name: Set environment information for schedule
if: ${{ steps.check_event.outputs.event_type == 'schedule' }}
run: |
LATEST_VERSION=$(curl --silent -m 10 --connect-timeout 5 https://api.github.com/repos/complytime/complyscribe/releases/latest | jq -r .tag_name)
{
echo "TAG=$LATEST_VERSION"
echo "NO_CACHE=true"
echo "BUILD_GIT_REF=$LATEST_VERSION"
echo "SKIP_TESTS=false"
} >> "$GITHUB_ENV"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check out
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ env.BUILD_GIT_REF }}
persist-credentials: false
- 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 }}
skip_tests: ${{ env.SKIP_TESTS }}
- name: Sign the image with GitHub OIDC Token
run: cosign sign --yes "$IMAGE"
env:
IMAGE: ${{ steps.build_publish_image.outputs.image_sha }}
- name: Verify image
run: |
cosign verify "$IMAGE" --certificate-identity-regexp="$SUBJECT" \
--certificate-oidc-issuer=https://token.actions.githubusercontent.com
env:
SUBJECT: https://github\.com/${{ github.repository_owner }}/complyscribe/\.github/.+
IMAGE: ${{ steps.build_publish_image.outputs.image_sha }}