Release Pipeline #2
Workflow file for this run
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: Release Pipeline | |
on: | |
workflow_dispatch: | |
jobs: | |
validate-ref: | |
name: Validate Git Ref | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fail if not tag | |
run: | | |
if [[ "${GITHUB_REF}" != refs/tags/v* ]]; then | |
echo "❌ This workflow must be triggered by a tag matching 'v*'." | |
exit 1 | |
fi | |
code-quality-and-tests: | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: validate-ref | |
uses: ./.github/workflows/code-quality-and-tests.yml | |
docker-build-push: | |
name: Docker Build and Push | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: [validate-ref, code-quality-and-tests] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.ref || github.ref }} | |
- name: Set up Docker | |
uses: docker/setup-buildx-action@v3 | |
- id: vars | |
name: Determine image tag | |
run: | | |
RELEASE_VERSION="${GITHUB_REF#refs/tags/v}" | |
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_OUTPUT | |
- name: Build and Push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ops/deploy/docker/Dockerfile | |
platforms: linux/amd64 | |
push: true | |
provenance: false | |
build-args: | | |
VERSION=${{ steps.vars.outputs.RELEASE_VERSION }} | |
BUILD_DATE=${{ github.run_started_at }} | |
GIT_COMMIT=${{ github.sha }} | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/realworld:${{ steps.vars.outputs.RELEASE_VERSION }} | |
ghcr.io/${{ github.repository_owner }}/realworld:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |