-
Notifications
You must be signed in to change notification settings - Fork 61
181 lines (160 loc) · 5.84 KB
/
Copy pathgcp-build.yml
File metadata and controls
181 lines (160 loc) · 5.84 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: "GCP: Build Image"
on:
workflow_dispatch:
inputs:
date_time_stamp:
description: 'Custom date+time stamp, YYYYMMDDhhmmss'
required: false
default: ''
version_major:
description: 'AlmaLinux major version'
required: true
default: '10'
type: choice
options:
- 10-kitten
- 10
- 9
- 8
self-hosted:
description: "Build aarch64 image on self-hosted runner"
required: true
type: boolean
default: true
store_as_artifact:
description: "Store images to the workflow Artifacts"
required: true
type: boolean
default: false
upload_to_s3:
description: "Upload to S3 Bucket"
required: true
type: boolean
default: true
notify_mattermost:
description: "Send notification to Mattermost"
required: true
type: boolean
default: true
env:
PACKER_GITHUB_API_TOKEN: ${{ secrets.GIT_HUB_TOKEN }}
jobs:
init-data:
name: Initialize common data
runs-on: ubuntu-24.04
outputs:
time_stamp: ${{ steps.date-time-stamp.outputs.time_stamp }}
date_stamp: ${{ steps.date-time-stamp.outputs.date_stamp }}
steps:
- name: Date+time stamp
id: date-time-stamp
run: |
# date+time stamp, YYYYMMDDhhmmss
if [ "${{ inputs.date_time_stamp }}" != "" ]; then
date_time_stamp="${{ inputs.date_time_stamp }}"
else
date_time_stamp=$(date -u '+%Y%m%d%H%M%S')
fi
echo "time_stamp=${date_time_stamp}" >> $GITHUB_OUTPUT
# date stamp, YYYYMMDD
date_stamp=${date_time_stamp:0:-6}
echo "date_stamp=${date_stamp}" >> "$GITHUB_OUTPUT"
build-gcp-x86_64:
name: ${{ inputs.version_major }} gcp-x86_64 image
permissions:
id-token: write
contents: read
needs: [init-data]
runs-on: >-
${{
github.repository_owner == 'AlmaLinux' &&
format('runs-on={0}/family=c7i.metal-24xl+c7a.metal-48xl+*8gd.metal*/image=ubuntu24-full-x64', github.run_id)
||
'ubuntu-24.04'
}}
env:
TIME_STAMP: ${{ needs.init-data.outputs.time_stamp }}
DATE_STAMP: ${{ needs.init-data.outputs.date_stamp }}
steps:
- name: Checkout ${{ github.action_repository }}
uses: actions/checkout@v6
- uses: ./.github/actions/gcp-build-steps
name: ${{ inputs.version_major }} gcp-x86_64 image
with:
variant: ${{ inputs.version_major }}
arch: x86_64
S3_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
S3_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ vars.AWS_REGION }}
AWS_S3_BUCKET: ${{ vars.AWS_S3_BUCKET }}
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
MATTERMOST_CHANNEL: ${{ vars.MATTERMOST_CHANNEL }}
store_as_artifact: ${{ inputs.store_as_artifact }}
upload_to_s3: ${{ inputs.upload_to_s3 }}
notify_mattermost: ${{ inputs.notify_mattermost }}
runner: ${{ github.repository_owner == 'AlmaLinux' && 'aws-ec2' || 'gh_hosted' }}
env:
PACKER_GITHUB_API_TOKEN: ${{ secrets.GIT_HUB_TOKEN }}
start-self-hosted-runner:
name: ${{ inputs.version_major }} gcp-aarch64 runner
if: ${{ inputs.self-hosted }}
runs-on: ubuntu-24.04
needs: [init-data]
steps:
- name: Setup and start runner
if: github.repository_owner != 'AlmaLinux'
uses: NextChapterSoftware/ec2-action-builder@v1.10
with:
github_token: ${{ secrets.GIT_HUB_TOKEN }}
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: ${{ vars.AWS_REGION }}
ec2_ami_id: ${{ secrets.EC2_AMI_ID_AL9_AARCH64 }}
ec2_subnet_id: ${{ secrets.EC2_SUBNET_ID }}
ec2_security_group_id: ${{ secrets.EC2_SECURITY_GROUP_ID }}
ec2_instance_type: a1.metal
ec2_root_disk_size_gb: "16"
ec2_root_disk_ebs_class: "gp3"
ec2_instance_ttl: 30
ec2_spot_instance_strategy: None
ec2_instance_tags: >
[
{"Key": "Project", "Value": "GitHub Actions Self-hosted Runners"}
]
build-gcp-aarch64:
name: ${{ inputs.version_major }} gcp-aarch64 image
permissions:
id-token: write
contents: read
if: ${{ inputs.self-hosted }}
needs: [init-data, start-self-hosted-runner]
runs-on: >-
${{
github.repository_owner == 'AlmaLinux' &&
format('runs-on={0}/family=c7i.metal-24xl+c7a.metal-48xl+*8gd.metal*/image=ubuntu24-full-arm64', github.run_id)
||
github.run_id
}}
env:
TIME_STAMP: ${{ needs.init-data.outputs.time_stamp }}
DATE_STAMP: ${{ needs.init-data.outputs.date_stamp }}
steps:
- name: Checkout ${{ github.action_repository }}
uses: actions/checkout@v6
- uses: ./.github/actions/gcp-build-steps
name: ${{ inputs.version_major }} gcp-aarch64 image
with:
variant: ${{ inputs.version_major }}
arch: aarch64
S3_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
S3_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ vars.AWS_REGION }}
AWS_S3_BUCKET: ${{ vars.AWS_S3_BUCKET }}
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
MATTERMOST_CHANNEL: ${{ vars.MATTERMOST_CHANNEL }}
store_as_artifact: ${{ inputs.store_as_artifact }}
upload_to_s3: ${{ inputs.upload_to_s3 }}
notify_mattermost: ${{ inputs.notify_mattermost }}
runner: aws-ec2
env:
PACKER_GITHUB_API_TOKEN: ${{ secrets.GIT_HUB_TOKEN }}