Skip to content

aws-codegen

aws-codegen #1030

Workflow file for this run

name: aws-codegen
on:
push:
branches:
- master
workflow_dispatch:
schedule:
## Scheduled nightly at 00:23
- cron: '23 0 * * *'
jobs:
check:
runs-on: ubuntu-20.04
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 "CURRENT_TAG=${CURRENT_TAG}" >> $GITHUB_OUTPUT
- name: Get latest AWS SDK Go tag
uses: octokit/[email protected]
id: latest-tag-request
with:
route: GET /repos/{owner}/{repo}/releases/latest
owner: aws
repo: aws-sdk-go-v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set it to the output
id: latest-tag
run: |
tag_name="${{ fromJson(steps.latest-tag-request.outputs.data).tag_name }}"
echo "LATEST_TAG=${tag_name}" >> $GITHUB_OUTPUT
generate:
runs-on: ubuntu-20.04
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"
ELIXIR_VERSION: "1.13.4"
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_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
mix deps.get
- name: Generate aws-elixir
env:
SPEC_PATH: ../aws-sdk-go-v2/codegen/sdk-codegen/aws-models
TEMPLATE_PATH: priv
ELIXIR_OUTPUT_PATH: ../../lib/aws/generated
run: |
# Jump to the codegen
cd tmp/aws-codegen
mix deps.get
# Remove first the existing files
rm -rf $ELIXIR_OUTPUT_PATH
mkdir -p $ELIXIR_OUTPUT_PATH
mix run generate.exs elixir $SPEC_PATH $TEMPLATE_PATH $ELIXIR_OUTPUT_PATH
- name: Test generated code
run: |
mix test
- 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 lib/aws/generated
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