-
Notifications
You must be signed in to change notification settings - Fork 9
75 lines (62 loc) · 2.36 KB
/
build-go-sdk.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
name: Generate Go SDK
on:
workflow_dispatch:
inputs:
version:
description: Version (without v)
required: true
jobs:
generate-go-sdk:
runs-on: ubuntu-latest
permissions:
contents: read
name: Build Lago Go SDK
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Checkout Lago Go Repository
uses: actions/checkout@v3
with:
repository: getlago/lago-go
token: ${{ secrets.GH_TOKEN }}
ref: main
path: './go-client'
- name: Init API version
id: init_version
run: |
OPENAPI_VERSION=`grep ' version:' openapi.yaml | tail -n1 | cut -c 12-`
[[ ! -z "${{ github.event.inputs.version }}" ]] && CURRENT_VERSION=${{ github.event.inputs.version }} || CURRENT_VERSION=$OPENAPI_VERSION
# Set version into generator config
sed -i "s/API_VERSION/$CURRENT_VERSION/" generators/go/config.yaml
echo "api_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
- name: Generate Go SDK
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: go
openapi-file: openapi.yaml
config-file: generators/go/config.yaml
template-dir: generators/go
- name: Open PR with changes on Lago Go Repository
run: |
API_VERSION="${{ steps.init_version.outputs.api_version }}"
BRANCH_NAME="version-${API_VERSION//./-}"
COMMIT_MESSAGE="misc: Version v$API_VERSION"
# Move into client folder
cd go-client
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# Commit and push the changes in a new feature branch
git checkout -b $BRANCH_NAME
git add .
git commit -m "$COMMIT_MESSAGE"
git push origin $BRANCH_NAME
# Store credentials for the Github CLI
echo "${{ secrets.GH_TOKEN }}" > access_token.txt
# Authorize GitHub CLI for the current repository and
# create a pull-requests containing the updates.
gh auth login --with-token < access_token.txt
gh pr create \
--body "" \
--title "$COMMIT_MESSAGE" \
--head "$BRANCH_NAME" \
--base "main"