-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (117 loc) · 4.73 KB
/
build-app.yaml
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: build-flask-app
on:
workflow_dispatch
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
env:
BASE_IMAGE_REGISTRY: ${{ vars.BASE_IMAGE_REGISTRY }}
BASE_IMAGE_REPO: ${{ vars.BASE_IMAGE_REPO }}
BASE_IMAGE_TAG: ${{ vars.BASE_IMAGE_TAG }}
BASE_IMAGE_DIGEST: ${{ vars.BASE_IMAGE_DIGEST }}
NOTATION_EXPERIMENTAL: 1
TARGET_IMAGE_REGISTRY: ${{ vars.TARGET_IMAGE_REGISTRY }}
TARGET_IMAGE_REPO: flaskapp
TARGET_IMAGE_TAG: ${{ vars.TARGET_IMAGE_TAG }}
SIGNING_KEY_ID: ${{ vars.SIGNING_KEY_ID }}
jobs:
verify-base-image:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Display environment
run: |
echo "BASE_IMAGE_REGISTRY: $BASE_IMAGE_REGISTRY"
echo "BASE_IMAGE_REPO: $BASE_IMAGE_REPO"
echo "BASE_IMAGE_TAG: $BASE_IMAGE_TAG"
echo "BASE_IMAGE_DIGEST: $BASE_IMAGE_DIGEST"
echo "NOTATION_EXPERIMENTAL: $NOTATION_EXPERIMENTAL"
echo "TARGET_IMAGE_REGISTRY: $TARGET_IMAGE_REGISTRY"
echo "TARGET_IMAGE_REPO: $TARGET_IMAGE_REPO"
echo "TARGET_IMAGE_TAG: $TARGET_IMAGE_TAG"
echo "SIGNING_KEY_ID: $SIGNING_KEY_ID"
- name: Checkout the code
uses: actions/checkout@v4
- name: Setup Notation CLI
uses: notaryproject/notation-action/setup@v1
with:
version: "1.0.0"
- name: Setup ORAS CLI
uses: oras-project/setup-oras@v1
with:
version: "1.0.0"
- name: Sign into Azure
uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Sign into ACR
run: |
az acr login --name ${{ env.BASE_IMAGE_REGISTRY }}
- name: Verify base image signature
uses: notaryproject/notation-action/verify@v1
with:
target_artifact_reference: "${{ env.BASE_IMAGE_REGISTRY }}/${{ env.BASE_IMAGE_REPO }}:${{ env.BASE_IMAGE_TAG }}"
trust_policy: ".github/trustpolicy/build-stage/trustpolicy.json"
trust_store: ".github/truststore"
allow_referrers_api: "true"
- name: Verify the image is not end-of-life
run: |
stages/build/src/verify-image-lifecycle.sh ${{ env.BASE_IMAGE_REGISTRY }} ${{ env.BASE_IMAGE_REPO }} ${{ env.BASE_IMAGE_TAG }} ${{ env.BASE_IMAGE_DIGEST }}
- name: Verify the image has no vulnerabilities
run: |
stages/build/src/verify-vulnerability-status.sh ${{ env.BASE_IMAGE_REGISTRY }} ${{ env.BASE_IMAGE_REPO }} ${{ env.BASE_IMAGE_TAG }} ${{ env.BASE_IMAGE_DIGEST }}
build-flask-app:
needs: verify-base-image
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Display environment
run: |
echo "BASE_IMAGE_REGISTRY: $BASE_IMAGE_REGISTRY"
echo "BASE_IMAGE_REPO: $BASE_IMAGE_REPO"
echo "BASE_IMAGE_TAG: $BASE_IMAGE_TAG"
echo "BASE_IMAGE_DIGEST: $BASE_IMAGE_DIGEST"
echo "NOTATION_EXPERIMENTAL: $NOTATION_EXPERIMENTAL"
echo "TARGET_IMAGE_REGISTRY: $TARGET_IMAGE_REGISTRY"
echo "TARGET_IMAGE_REPO: $TARGET_IMAGE_REPO"
echo "TARGET_IMAGE_TAG: $TARGET_IMAGE_TAG"
echo "SIGNING_KEY_ID: $SIGNING_KEY_ID"
- name: Checkout the code
uses: actions/checkout@v4
- name: Setup Notation CLI
uses: notaryproject/notation-action/setup@v1
with:
version: "1.0.0"
- name: Sign into Azure
uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Sign into ACR
run: |
az acr login --name ${{ env.BASE_IMAGE_REGISTRY }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push the Flask app image
uses: docker/build-push-action@v5
with:
context: ./sample
push: true
tags: ${{ env.TARGET_IMAGE_REGISTRY }}/${{ env.TARGET_IMAGE_REPO }}:${{ env.TARGET_IMAGE_TAG }}
build-args: |
BASE_IMAGE=${{ env.BASE_IMAGE_REGISTRY }}/${{ env.BASE_IMAGE_REPO }}:${{ env.BASE_IMAGE_TAG }}
- name: Sign the image with notation-azure-kv plugin
uses: notaryproject/notation-action/sign@v1
with:
plugin_name: azure-kv
plugin_url: https://github.com/Azure/notation-azure-kv/releases/download/v1.0.1/notation-azure-kv_1.0.1_linux_amd64.tar.gz
plugin_checksum: f8a75d9234db90069d9eb5660e5374820edf36d710bd063f4ef81e7063d3810b
key_id: ${{ env.SIGNING_KEY_ID }}
target_artifact_reference: ${{ env.TARGET_IMAGE_REGISTRY }}/${{ env.TARGET_IMAGE_REPO }}:${{ env.TARGET_IMAGE_TAG }}
signature_format: cose