aws-codegen #1099
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: aws-codegen | |
on: | |
push: | |
branches: | |
- master | |
schedule: | |
## Scheduled nightly at 00:23 | |
- cron: '23 0 * * *' | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
name: Check if changed | |
strategy: | |
fail-fast: false | |
outputs: | |
current_tag: ${{ steps.current-tag.outputs.CURRENT_TAG }} | |
latest_tag: ${{ steps.latest-tag.outputs.LATEST_TAG }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get tag used for generated files | |
id: current-tag | |
run: | | |
# check if the file exist before | |
[[ -f .latest-tag-aws-sdk-go ]] && CURRENT_TAG=$(<.latest-tag-aws-sdk-go) || CURRENT_TAG='' | |
echo "::set-output name=CURRENT_TAG::${CURRENT_TAG}" | |
- name: Get latest AWS SDK Go tag | |
id: latest-tag | |
run: | | |
wget https://api.github.com/repos/aws/aws-sdk-go-v2/releases/latest | |
tag_name=$(cat latest | jq -r '.tag_name') | |
echo "::set-output name=LATEST_TAG::${tag_name}" | |
generate: | |
runs-on: ubuntu-latest | |
name: Update services | |
needs: check | |
if: ${{ needs.check.outputs.current_tag != needs.check.outputs.latest_tag }} | |
env: | |
LATEST_AWS_SDK_GO_TAG: ${{ needs.check.outputs.latest_tag }} | |
OTP_VERSION: "25.0.4" | |
ELIXIR_VERSION: "1.13.2" | |
REBAR3_VERSION: "3.20.0" | |
strategy: | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Remove any previously generated files | |
run: find src/ -type f -name "*.erl" -exec grep -l "DO NOT EDIT, AUTO-GENERATED CODE" {} \; | xargs rm -f | |
- uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{ env.OTP_VERSION }} | |
elixir-version: ${{ env.ELIXIR_VERSION }} | |
rebar3-version: ${{ env.REBAR3_VERSION }} | |
- name: Checkout aws/aws-sdk-go-v2 (official Go SDK) | |
uses: actions/checkout@v3 | |
with: | |
repository: aws/aws-sdk-go-v2 | |
path: tmp/aws-sdk-go-v2 | |
ref: ${{ env.LATEST_AWS_SDK_GO_TAG }} | |
- name: Checkout aws-codegen | |
uses: actions/checkout@v3 | |
with: | |
repository: aws-beam/aws-codegen | |
path: tmp/aws-codegen | |
- name: Install Dependencies | |
run: | | |
mix local.rebar --force | |
mix local.hex --force | |
rebar3 compile | |
- name: Generate aws-erlang | |
env: | |
SPEC_PATH: ../aws-sdk-go-v2/codegen/sdk-codegen/aws-models | |
TEMPLATE_PATH: priv | |
ERLANG_OUTPUT_PATH: ../../src | |
run: | | |
# Jump to the codegen | |
cd tmp/aws-codegen | |
mix deps.get | |
mkdir -p $ERLANG_OUTPUT_PATH | |
mix run generate.exs erlang $SPEC_PATH $TEMPLATE_PATH $ERLANG_OUTPUT_PATH | |
- name: Test generated code | |
run: | | |
rebar3 eunit | |
- name: Update latest tag file | |
run: | | |
echo "${LATEST_AWS_SDK_GO_TAG}" > .latest-tag-aws-sdk-go | |
- name: Commit files | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "github-actions[bot]" | |
git add src/* | |
git add .latest-tag-aws-sdk-go | |
echo "Update services based on ${{ env.LATEST_AWS_SDK_GO_TAG }} of AWS Go SDK" >> commit-msg | |
echo >> commit-msg | |
echo "Reference: https://github.com/aws/aws-sdk-go-v2/releases/tag/${{ env.LATEST_AWS_SDK_GO_TAG }}" >> commit-msg | |
git commit -F commit-msg | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: master |