forked from aws/aws-sam-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (46 loc) · 2.16 KB
/
update_app_templates_hash.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
name: Update aws/aws-sam-cli with latest commit hash from aws/aws-sam-cli-app-templates
on:
schedule:
- cron: "0 * * * *" # run at the top of every hour
workflow_dispatch: {}
jobs:
updateCommitHash:
permissions:
pull-requests: write
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout App Templates
uses: actions/checkout@v3
with:
repository: aws/aws-sam-cli-app-templates
path: aws-sam-cli-app-templates
- name: Checkout SAM CLI
uses: actions/checkout@v3
with:
repository: aws/aws-sam-cli
path: aws-sam-cli
- name: Update hash & commit
run: |
git config --global user.email "[email protected]"
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."