-
Notifications
You must be signed in to change notification settings - Fork 671
80 lines (68 loc) · 2.14 KB
/
build-public-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
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
name: build-public-ami
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to create AMI from'
required: true
push:
tags:
- "*"
env:
PACKER_VERSION: "1.10.2"
PYTHON3_BOTO3_VERSION: "1.20.34+dfsg-1"
jobs:
build-public-ami-and-upload:
runs-on: ubuntu-22.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '~1.21.8'
check-latest: true
- run: go version
- name: Install aws cli
run: |
sudo apt update
sudo apt-get -y install python3-boto3=${PYTHON3_BOTO3_VERSION}
- name: Get the tag
id: get_tag
run: |
if [[ ${{ github.event_name }} == 'push' ]];
then
echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
else
echo "TAG=${{ inputs.tag }}" >> $GITHUB_ENV
fi
shell: bash
- name: Set whether to skip ami creation in packer
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "Setting SKIP_CREATE_AMI to False"
echo "SKIP_CREATE_AMI=False" >> $GITHUB_ENV
fi
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.MARKETPLACE_ID }}
aws-secret-access-key: ${{ secrets.MARKETPLACE_KEY }}
aws-region: us-east-1
- name: Setup `packer`
uses: hashicorp/setup-packer@main
id: setup
with:
version: ${{ env.PACKER_VERSION }}
- name: Run `packer init`
id: init
run: "packer init ./.github/packer/ubuntu-jammy-x86_64-public-ami.pkr.hcl"
- name: Run `packer validate`
id: validate
run: "packer validate ./.github/packer/ubuntu-jammy-x86_64-public-ami.pkr.hcl"
- name: Create AMI and upload to marketplace
run: |
./.github/workflows/update-ami.py
env:
TAG: ${{ env.TAG }}
PRODUCT_ID: ${{ secrets.MARKETPLACE_PRODUCT }}
ROLE_ARN: ${{ secrets.MARKETPLACE_ROLE }}