-
Notifications
You must be signed in to change notification settings - Fork 4
104 lines (91 loc) · 2.94 KB
/
container-aca.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Build image and push to ACA
on:
push:
tags:
- "*"
workflow_dispatch:
env:
REGISTRY: ghcr.io
REPO: r-techsupport
IMAGE: hyde
jobs:
image-builder:
runs-on: ubuntu-latest
outputs:
digest: ${{ steps.push.outputs.digest }}
permissions:
packages: 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
sbom-attestation:
runs-on: ubuntu-latest
needs: image-builder
permissions:
contents: write
attestations: write
id-token: write
steps:
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.REPO }}/${{ env.IMAGE}}
subject-digest: ${{ needs.image-builder.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 }}