Skip to content

Commit 88086a0

Browse files
authored
OPSEXP-3176 Automate AMI bumps with updatecli (#1133)
1 parent 6dc0c62 commit 88086a0

File tree

3 files changed

+143
-3
lines changed

3 files changed

+143
-3
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Update AMI
2+
3+
sources:
4+
{{- range $key, $ami := .amis }}
5+
src_{{ $key }}:
6+
kind: aws/ami
7+
spec:
8+
region: {{ requiredEnv "AWS_REGION" }}
9+
filters:
10+
- name: "owner-id"
11+
values: '{{ $ami.owner_id | default "*" }}'
12+
- name: "name"
13+
values: '{{ $ami.pattern }}'
14+
- name: "architecture"
15+
values: '{{ $ami.architecture | default "x86_64" }}'
16+
- name: "block-device-mapping.volume-type"
17+
values: '{{ $ami.volume_type | default "gp3" }}'
18+
src_name_{{ $key }}:
19+
kind: shell
20+
dependson:
21+
- src_{{ $key }}
22+
spec:
23+
command: aws ec2 describe-images --region {{ requiredEnv "AWS_REGION" }} --image-ids {{ source (printf "src_%s" $key) }} --query 'Images[0].Name' --output text
24+
environments:
25+
- name: PATH
26+
- name: AWS_ACCESS_KEY_ID
27+
- name: AWS_SECRET_ACCESS_KEY
28+
{{- end }}
29+
30+
targets:
31+
{{- range $key, $target := .targets }}
32+
yml_{{ $key }}:
33+
name: {{ $target.source }} bump
34+
kind: yaml
35+
sourceid: src_{{ $target.source }}
36+
scmid: "github"
37+
spec:
38+
engine: yamlpath # https://github.com/updatecli/updatecli/issues/4490
39+
file: '{{ $target.file }}'
40+
key: '{{ $target.key }}'
41+
comment: '{{ source (printf "src_name_%s" $target.source) }}'
42+
{{- end }}
43+
44+
actions:
45+
pr:
46+
kind: "github/pullrequest"
47+
scmid: "github"
48+
spec:
49+
title: "Bump AMIs versions"
50+
labels:
51+
- "updatecli"
52+
- "ec2-test"
53+
54+
scms:
55+
github:
56+
kind: "github"
57+
spec:
58+
owner: "Alfresco"
59+
repository: "alfresco-ansible-deployment"
60+
branch: "master"
61+
token: {{ requiredEnv "UPDATECLI_GITHUB_TOKEN" }}
62+
username: {{ requiredEnv "UPDATECLI_GITHUB_USERNAME" }}
63+
user: {{ requiredEnv "UPDATECLI_GITHUB_USERNAME" }}
64+
email: {{ requiredEnv "UPDATECLI_GITHUB_EMAIL" }}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
amis:
2+
rhel8:
3+
pattern: RHEL-8.10.0_HVM-*
4+
owner_id: "309956199498"
5+
rhel9:
6+
pattern: RHEL-9.4.0_HVM-*
7+
owner_id: "309956199498"
8+
rl8:
9+
pattern: Rocky-8-EC2-Base-8.10-*
10+
volume_type: gp2
11+
owner_id: "792107900819"
12+
rl9:
13+
pattern: Rocky-9-EC2-Base-9.4-*
14+
volume_type: gp2
15+
owner_id: "792107900819"
16+
ub22:
17+
pattern: ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*
18+
volume_type: gp2
19+
owner_id: "099720109477"
20+
ub24:
21+
pattern: ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-server-*
22+
owner_id: "099720109477"
23+
24+
targets:
25+
molecule_default_rhel8:
26+
file: molecule/default/vars-rhel8.yml
27+
key: $.MOLECULE_IT_IMAGE_ID
28+
source: rhel8
29+
molecule_default_rocky8:
30+
file: molecule/default/vars-rocky8.yml
31+
key: $.MOLECULE_IT_IMAGE_ID
32+
source: rl8
33+
molecule_default_rocky9:
34+
file: molecule/default/vars-rocky9.yml
35+
key: $.MOLECULE_IT_IMAGE_ID
36+
source: rl9
37+
molecule_default_ubuntu_community:
38+
file: molecule/default/vars-ubuntu-community.yml
39+
key: $.MOLECULE_IT_IMAGE_ID
40+
source: ub24
41+
molecule_default_ubuntu22_73:
42+
file: molecule/default/vars-ubuntu22-73.yml
43+
key: $.MOLECULE_IT_IMAGE_ID
44+
source: ub22
45+
molecule_multimachine:
46+
file: molecule/multimachine/vars.yml
47+
key: $.MOLECULE_IT_IMAGE_ID
48+
source: rhel9
49+
molecule_opensearch:
50+
file: molecule/opensearch/vars.yml
51+
key: $.MOLECULE_IT_IMAGE_ID
52+
source: rhel9

.github/workflows/bumpVersions.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
---
22
name: Bump versions
3-
run-name: Bump using alfresco-updatecli/${{ inputs.alfresco-updatecli-ref || 'master' }}
3+
run-name: Bump ${{ inputs.update-type || 'all' }} using alfresco-updatecli/${{ inputs.alfresco-updatecli-ref || 'master' }}
44

55
on:
6+
schedule:
7+
- cron: '52 6 * * 1'
68
push:
79
paths:
810
- .github/workflows/bumpVersions.yml
@@ -13,6 +15,12 @@ on:
1315
description: "The version to use for alfresco/alfresco-updatecli configs"
1416
type: string
1517
default: master
18+
update-type:
19+
description: 'Which dependencies to bump'
20+
type: choice
21+
options:
22+
- maven
23+
- ami
1624

1725
concurrency:
1826
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name || github.run_id }}
@@ -43,14 +51,16 @@ jobs:
4351
path: alfresco-updatecli
4452

4553
- name: Updatecli scm cache
54+
if: inputs.update-type == 'maven' || github.event_name == 'push'
4655
uses: actions/cache@v4
4756
with:
4857
path: /tmp/updatecli/github
4958
key: updatecli-v1-${{ hashFiles('.github/updatecli/updatecli_amps.tpl') }}
5059
restore-keys: |
5160
updatecli-v1-
5261
53-
- name: Updatecli apply
62+
- name: Updatecli apply for Maven
63+
if: inputs.update-type == 'maven' || github.event_name == 'push'
5464
shell: bash
5565
run: |
5666
set -x
@@ -67,7 +77,21 @@ jobs:
6777
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
6878
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
6979
UPDATECLI_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
70-
UPDATECLI_GITHUB_USERNAME: ${{ vars.BOT_GITHUB_USERNAME}}
80+
UPDATECLI_GITHUB_USERNAME: ${{ vars.BOT_GITHUB_USERNAME }}
81+
82+
- name: Updatecli apply for AMIs
83+
if: inputs.update-type == 'ami' || github.event_name == 'push' || github.event_name == 'schedule'
84+
shell: bash
85+
run: |
86+
updatecli apply --config .github/updatecli/updatecli_amis.tpl \
87+
-v .github/updatecli/updatecli_amis_values.yml
88+
env:
89+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
90+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
91+
AWS_REGION: eu-west-1
92+
UPDATECLI_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
93+
UPDATECLI_GITHUB_USERNAME: ${{ vars.BOT_GITHUB_USERNAME }}
94+
UPDATECLI_GITHUB_EMAIL: ${{ vars.BOT_GITHUB_EMAIL }}
7195

7296
- name: Git Auto Commit
7397
uses: stefanzweifel/git-auto-commit-action@e348103e9026cc0eee72ae06630dbe30c8bf7a79 # v5.1.0

0 commit comments

Comments
 (0)