-
Notifications
You must be signed in to change notification settings - Fork 1.2k
153 lines (140 loc) · 6.5 KB
/
automated-updates-to-sam-cli.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
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
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: Checkout App Templates
uses: actions/checkout@v4
with:
repository: aws/aws-sam-cli-app-templates
path: aws-sam-cli-app-templates
- name: Checkout SAM CLI
uses: actions/checkout@v4
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: Checkout SAM
uses: actions/checkout@v4
with:
repository: aws/serverless-application-model
path: serverless-application-model
ref: main
fetch-depth: 0
- name: Checkout SAM CLI
uses: actions/checkout@v4
with:
repository: aws/aws-sam-cli
path: aws-sam-cli
- 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
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: Checkout Lambda Builders
uses: actions/checkout@v4
with:
repository: aws/aws-lambda-builders
path: aws-lambda-builders
ref: main
fetch-depth: 0
- name: Checkout SAM CLI
uses: actions/checkout@v4
with:
repository: aws/aws-sam-cli
path: aws-sam-cli
- 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
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"