Update aws/aws-sam-cli with latest commit hash from aws/aws-sam-cli-app-templates and aws-sam-translator version #1034
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "[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." --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 "[email protected]" | |
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 "[email protected]" | |
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" |