Generate Code from AWS documentation #4553
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: Generate Code from AWS documentation | |
on: | |
schedule: | |
# Why 1:57 not and 2:00? Because most hourly jobs probably run at the hour. | |
# Keeping concurrent jobs low reduces hardware requirements, being nice to | |
# GitHub and the environment. | |
- cron: 57 1 * * * | |
workflow_dispatch: | |
inputs: | |
command: | |
description: make command to run | |
required: true | |
default: generate | |
type: choice | |
options: | |
- generate | |
- generate-force | |
jobs: | |
generate: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Install dependencies | |
run: make install | |
- name: Generate code | |
run: make generate | |
if: ${{ github.event_name == 'schedule' }} | |
- name: Generate code | |
run: make ${{ github.event.inputs.command }} | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
- name: Check for changes # we expect at least 3 changes or we won't trigger a new release | |
id: changes | |
run: | | |
set -xuo pipefail # we intentionally do not use -e here, as rc=1 means we have changes | |
git diff | |
echo "CHANGED=$(git diff --unified=0 -- stats | grep '^[+-]' | grep -v +++ | grep -v -- --- | wc -l | xargs)" >> $GITHUB_OUTPUT | |
# fail if the index file does not exist. | |
# this could happen if we cannot reach the AWS documentation, or the | |
# format of the documentation has changed and therefore cannot generate | |
# code. | |
- name: Failsafe | |
run: test -e lib/index.ts || exit 1 | |
if: steps.changes.outputs.CHANGED >= 3 | |
- name: Configure git | |
run: | | |
set -xeuo pipefail | |
git config --local user.email "${{ secrets.RELEASE_MAIL }}" | |
git config --local user.name "udondan" | |
if: steps.changes.outputs.CHANGED >= 3 | |
- name: Update version refs | |
run: | | |
set -xeuo pipefail | |
perl -pi -e 's/^(\d+\.)(\d+)(\.\d+)$/($1).($2+1).".0"/e' VERSION | |
make update-version-refs | |
if: steps.changes.outputs.CHANGED >= 3 | |
- name: Update stats in documentation | |
run: make stats | |
if: steps.changes.outputs.CHANGED >= 3 | |
- name: Generate changelog for next release | |
run: | | |
set -xeuo pipefail | |
make changelog | |
git add CHANGELOG/* | |
if: steps.changes.outputs.CHANGED >= 3 | |
- name: Regenerate code example results | |
run: make regenerate-code-example-results | |
if: steps.changes.outputs.CHANGED >= 3 | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Add all changes | |
run: | | |
set -xeuo pipefail | |
rm -rf package-lock.json node_modules *.tsbuildinfo && | |
git add * | |
if: steps.changes.outputs.CHANGED >= 3 | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ secrets.OVERRIDE_TOKEN }} | |
commit-message: Adds latest IAM updates from AWS | |
title: Adds latest IAM updates from AWS | |
body: Adds latest IAM updates from AWS | |
branch: iam-updates | |
delete-branch: true | |
committer: udondan <${{ secrets.RELEASE_MAIL }}> | |
author: udondan <${{ secrets.RELEASE_MAIL }}> | |
labels: automerge | |
if: steps.changes.outputs.CHANGED >= 3 |