-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathautomated-updates-to-sam-cli.yml
More file actions
199 lines (179 loc) · 8.04 KB
/
automated-updates-to-sam-cli.yml
File metadata and controls
199 lines (179 loc) · 8.04 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: Update aws/aws-sam-cli with latest commit hash from aws/aws-sam-cli-app-templates and aws-sam-translator version
on:
schedule:
- cron: "0 0/4 * * *" # run at the top of every 4 hour
workflow_dispatch: {}
jobs:
updateInitAppTemplatesCommitHash:
permissions:
pull-requests: write
contents: write
if: github.repository == 'aws/aws-sam-cli'
runs-on: ubuntu-latest
steps:
- name: Check if PR already exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_COUNT=$(gh pr list --repo aws/aws-sam-cli --head update_app_templates_hash --json id --jq length)
if [ "$PR_COUNT" -ge 1 ]; then
echo "PR already exists for update_app_templates_hash, skipping workflow"
exit 1
fi
- name: Checkout App Templates
uses: actions/checkout@v6
with:
repository: aws/aws-sam-cli-app-templates
path: aws-sam-cli-app-templates
- name: Checkout SAM CLI
uses: actions/checkout@v6
with:
repository: aws/aws-sam-cli
path: aws-sam-cli
- name: Update hash & commit
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
cd aws-sam-cli-app-templates
APP_TEMPLATES_COMMIT_HASH=$(git rev-parse HEAD)
cd ../aws-sam-cli
git checkout -b update_app_templates_hash
git reset --hard develop
cat <<< "$(jq --arg commit_hash "$APP_TEMPLATES_COMMIT_HASH" --indent 4 '.app_template_repo_commit = $commit_hash' samcli/runtime_config.json)" > samcli/runtime_config.json
git status
git diff --quiet && exit 0 # exit if there is no change
echo "is_hash_changed=1" >> $GITHUB_ENV # set env variable for next step run decision
git add -u
git commit -m "feat: updating app templates repo hash with ($APP_TEMPLATES_COMMIT_HASH)"
- name: Raise PR for SAM CLI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ env.is_hash_changed == 1 }} # run only if there was a change
run: |
cd aws-sam-cli
git push --force origin update_app_templates_hash
gh pr list --repo aws/aws-sam-cli --head update_app_templates_hash --json id --jq length | grep 1 && exit 0 # exit if there is existing pr
gh pr create --base develop --head update_app_templates_hash --title "feat: update SAM CLI with latest App Templates commit hash" --body "This PR & commit is automatically created from App Templates repo to update the SAM CLI with latest hash of the App Templates." --label "pr/internal"
updateSAMTranslator:
permissions:
pull-requests: write
contents: write
if: github.repository == 'aws/aws-sam-cli'
runs-on: ubuntu-latest
steps:
- name: Check if PR already exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_COUNT=$(gh pr list --repo aws/aws-sam-cli --head update_sam_transform_version --json id --jq length)
if [ "$PR_COUNT" -ge 1 ]; then
echo "PR already exists for update_sam_transform_version, skipping workflow"
exit 1
fi
- name: Checkout SAM
uses: actions/checkout@v6
with:
repository: aws/serverless-application-model
path: serverless-application-model
ref: main
fetch-depth: 0
- name: Checkout SAM CLI
uses: actions/checkout@v6
with:
repository: aws/aws-sam-cli
path: aws-sam-cli
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Update aws-sam-translator & commit
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
cd serverless-application-model
SAM_T_CUR_VERSION=$(git describe --tags --abbrev=0 | sed 's/v//')
echo "SAM-T cur version is $SAM_T_CUR_VERSION"
cd ../aws-sam-cli
git checkout -b update_sam_transform_version
SAM_T_PRE_VERSION=$(grep "aws-sam-translator=" requirements/base.txt)
echo "SAM-T pre version is $SAM_T_PRE_VERSION"
git reset --hard develop
sed -i "s/$SAM_T_PRE_VERSION/aws-sam-translator==$SAM_T_CUR_VERSION/g" requirements/base.txt
cp -r ../serverless-application-model/tests/translator/input ./tests/functional/commands/validate/lib/models
make update-reproducible-reqs-uv
git status
git diff --quiet && exit 0 # exit if there is no change
echo "is_new_sam_t=1" >> $GITHUB_ENV # set env variable for next step run decision
git add -u
git commit -m "chore: update aws-sam-translator to $SAM_T_CUR_VERSION"
- name: Raise PR for SAM CLI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ env.is_new_sam_t == 1 }} # run only if there was a change
run: |
cd aws-sam-cli
git push --force origin update_sam_transform_version
gh pr list --repo aws/aws-sam-cli --head update_sam_transform_version --json id --jq length | grep 1 && exit 0 # exit if there is existing pr
gh pr create --base develop --head update_sam_transform_version --fill --label "pr/internal"
updateAWSLambdaBuilders:
permissions:
pull-requests: write
contents: write
if: github.repository == 'aws/aws-sam-cli'
runs-on: ubuntu-latest
steps:
- name: Check if PR already exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_COUNT=$(gh pr list --repo aws/aws-sam-cli --head update_lambda_builders_version --json id --jq length)
if [ "$PR_COUNT" -ge 1 ]; then
echo "PR already exists for update_lambda_builders_version, skipping workflow"
exit 1
fi
- name: Checkout Lambda Builders
uses: actions/checkout@v6
with:
repository: aws/aws-lambda-builders
path: aws-lambda-builders
ref: main
fetch-depth: 0
- name: Checkout SAM CLI
uses: actions/checkout@v6
with:
repository: aws/aws-sam-cli
path: aws-sam-cli
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Upgrade aws_lambda_builders & commit
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
cd aws-lambda-builders
BUILDERS_CUR_VERSION=$(git describe --tags --abbrev=0 | sed 's/v//')
echo "Lambda Builders cur version is $BUILDERS_CUR_VERSION"
cd ../aws-sam-cli
git checkout -b update_lambda_builders_version
BUILDERS_PRE_VERSION=$(grep "aws_lambda_builders=" requirements/base.txt)
echo "Lambda Builders pre version is $BUILDERS_PRE_VERSION"
git reset --hard develop
sed -i "s/$BUILDERS_PRE_VERSION/aws_lambda_builders==$BUILDERS_CUR_VERSION/g" requirements/base.txt
make update-reproducible-reqs-uv
git status
git diff --quiet && exit 0 # exit if there is no change
echo "is_new_lambda_builders=1" >> $GITHUB_ENV # set env variable for next step run decision
git add -u
git commit -m "chore: update aws_lambda_builders to $BUILDERS_CUR_VERSION"
- name: Raise PR for SAM CLI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ env.is_new_lambda_builders == 1 }} # run only if there was a change
run: |
cd aws-sam-cli
git push --force origin update_lambda_builders_version
gh pr list --repo aws/aws-sam-cli --head update_lambda_builders_version --json id --jq length | grep 1 && exit 0 # exit if there is existing pr
gh pr create --base develop --head update_lambda_builders_version --fill --label "pr/internal"