-
Notifications
You must be signed in to change notification settings - Fork 132
127 lines (107 loc) · 3.62 KB
/
codegen.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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