-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (47 loc) · 1.64 KB
/
_build-ami.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
name: Build AMI
on:
workflow_call:
inputs:
image-spec:
type: string
required: true
description: "The path to the image.json file"
image-ref:
type: string
required: true
description: "The full reference to the image"
jobs:
build-ami:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: read
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Generate AMI Metadata
id: generate-metadata
run: |
AMI_NAME=$(jq -r '.name' ${{ inputs.image-spec }})-$(date -u +"%Y%m%d%H%M%S")
if [ ${GITHUB_REF:0:10} = "refs/pull/" ]; then
AMI_NAME="pr$GITHUB_HEAD_REF-$AMI_NAME"
else
echo "AMI_NAME=$AMI_NAME" >> $GITHUB_OUTPUT
fi
IMAGE_NAME=$(jq -r '.name' ${{ inputs.image-spec }})
IMAGE_REGISTRY=ghcr.io/${{ github.repository }}/$IMAGE_NAME
echo "IMAGE_REGISTRY=$IMAGE_REGISTRY" >> $GITHUB_OUTPUT
- name: Build AMI
id: build
uses: ./.github/actions/build-ami
with:
ami-name: ${{ steps.generate-metadata.outputs.AMI_NAME }}
image-ref: ${{ inputs.image-ref }}
registry: ghcr.io/${{ github.repository }}/$IMAGE_NAME
registry-password: ${{ secrets.GITHUB_TOKEN }}
aws-iam-role: ${{ vars.DEPLOY_IAM_ROLE }}
aws-region: ${{ vars.AWS_REGION }}
aws-output-bucket: ${{ vars.AWS_AMI_BUCKET }}
osbuild-config-file: ./images/.osbuild/config.toml
osbuild-output-dir: /tmp/osbuild-output