Publish Quay.io #4
This file contains hidden or 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 Quay.io | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| - 'dev-*' | |
| tags: | |
| - '*' | |
| workflow_dispatch: | |
| jobs: | |
| wait-for-tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Wait for Unit Tests | |
| uses: fountainhead/action-wait-for-check@v1.2.0 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| checkName: unit-tests | |
| ref: ${{ github.sha }} | |
| timeoutSeconds: 600 | |
| intervalSeconds: 15 | |
| - name: Wait for E2E Tests | |
| uses: fountainhead/action-wait-for-check@v1.2.0 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| checkName: e2e | |
| ref: ${{ github.sha }} | |
| timeoutSeconds: 600 | |
| intervalSeconds: 15 | |
| publish: | |
| needs: wait-for-tests | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| env: | |
| QUAY_USER: ${{ vars.QUAY_USER }} | |
| QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }} | |
| QUAY_IMAGE: ${{ vars.QUAY_IMAGE }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Validate configuration | |
| run: | | |
| set -euo pipefail | |
| for var in QUAY_USER QUAY_PASSWORD QUAY_IMAGE; do | |
| if [ -z "${!var}" ]; then | |
| echo "Missing value for $var" >&2 | |
| exit 1 | |
| fi | |
| done | |
| - name: Determine tags | |
| run: | | |
| set -euo pipefail | |
| ref="${GITHUB_REF}" | |
| ref_name="${GITHUB_REF_NAME}" | |
| sha_short="$(printf '%s' "${GITHUB_SHA}" | cut -c1-7)" | |
| if [[ "${ref}" == refs/tags/* ]]; then | |
| suffix="${ref#refs/tags/}" | |
| elif [[ "${ref_name}" == "main" ]]; then | |
| suffix="latest" | |
| else | |
| slug="$(printf '%s' "${ref_name}" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g' | sed -E 's/^-+|-+$//g')" | |
| [[ -z "${slug}" ]] && slug="sha-${sha_short}" | |
| suffix="${slug}" | |
| fi | |
| base_tag="quay.io/${QUAY_IMAGE}:${suffix}" | |
| echo "BASE_TAG=${base_tag}" >> "${GITHUB_ENV}" | |
| echo "AMD64_TAG=${base_tag}-amd64" >> "${GITHUB_ENV}" | |
| echo "ARM64_TAG=${base_tag}-arm64" >> "${GITHUB_ENV}" | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Quay.io | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: quay.io | |
| username: ${{ env.QUAY_USER }} | |
| password: ${{ env.QUAY_PASSWORD }} | |
| - name: Build and push linux/amd64 image | |
| env: | |
| BASE_TAG: ${{ env.BASE_TAG }} | |
| AMD64_TAG: ${{ env.AMD64_TAG }} | |
| run: | | |
| set -euo pipefail | |
| docker buildx build \ | |
| --platform linux/amd64 \ | |
| --push \ | |
| --tag "${AMD64_TAG}" \ | |
| --tag "${BASE_TAG}" \ | |
| . | |
| - name: Build and push linux/arm64 image | |
| env: | |
| ARM64_TAG: ${{ env.ARM64_TAG }} | |
| run: | | |
| set -euo pipefail | |
| docker buildx build \ | |
| --platform linux/arm64 \ | |
| --push \ | |
| --tag "${ARM64_TAG}" \ | |
| . |