CD #9
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: CD | |
| on: # yamllint disable-line rule:truthy | |
| push: | |
| branches: ["main"] | |
| tags: ["v*.*.*"] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| concurrency: | |
| group: cd | |
| cancel-in-progress: true | |
| jobs: | |
| build-and-push: | |
| name: Build and push image to GHCR | |
| runs-on: ubuntu-latest | |
| env: | |
| REGISTRY: ghcr.io | |
| # Lowercase, hardcoded: GHCR image names must be lowercase, and | |
| # github.repository would be `sessatakuma/API-tools` (mixed case). | |
| # Must match deploy/compose.yml's api-tools image in jpcorrect-backend. | |
| IMAGE_NAME: sessatakuma/api-tools | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=dev,enable={{is_default_branch}} | |
| type=sha,format=short | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=raw,value=stable,enable=${{ startsWith(github.ref, 'refs/tags/v') }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| file: ./Dockerfile # adjust if the api-tools Dockerfile path differs | |
| platforms: linux/amd64 | |
| push: true | |
| provenance: true | |
| sbom: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |