Skip to content

Publish Docker amd64 image #137

Publish Docker amd64 image

Publish Docker amd64 image #137

name: Publish Docker amd64 image
on:
push:
branches:
- main
workflow_dispatch:
schedule:
- cron: "0 13 * * *"
env:
REGISTRY: ghcr.io
REPO: r-techsupport
IMAGE: hyde
jobs:
image-builder:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write
attestations: write
steps:
- name: Checkout
uses: actions/checkout@v4
- 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 the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
context: git
images: ${{ env.REGISTRY }}/${{ env.REPO }}/${{ env.IMAGE }}
flavor: latest=auto
tags: |
type=sha,enable=true,priority=100,prefix=,suffix=,format=long
type=raw,value=devel,enable=${{ github.ref != format('refs/heads/{0}', 'main') }}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Containerfile
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.REPO }}/${{ env.IMAGE}}
subject-digest: ${{ steps.push.outputs.digest }}
- name: Generate SBOM
uses: anchore/sbom-action@v0
with:
image: ${{ env.REGISTRY }}/${{ env.REPO }}/${{ env.IMAGE}}:${{ github.sha }}
artifact-name: ${{ env.IMAGE }}-${{ github.sha }}.spdx
format: spdx-json
upload-artifact: true
upload-artifact-retention: 7
deploy-aca:
runs-on: ubuntu-latest
needs: image-builder
env:
RESOURCE_GROUP: rts-infra
CONTAINER_APP: hyde
steps:
- name: Azure login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Copy revision
uses: azure/CLI@v1
with:
azcliversion: 2.61.0
inlineScript: |
az containerapp revision copy -n ${{ env.CONTAINER_APP }} -g ${{ env.RESOURCE_GROUP }} \
--image ${{ env.REGISTRY }}/${{ env.REPO }}/${{ env.IMAGE}}:${{ github.sha }} \
--revision-suffix gha-${{ github.run_id }}-${{ github.run_attempt }}