-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (130 loc) · 4.53 KB
/
update-client.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
128
129
130
131
132
133
134
135
136
137
138
name: Update Client
# Set environment variables available in all jobs and steps
env:
python_version: "3.9"
go_module: "client"
on:
workflow_call:
inputs:
branch:
description:
"Branch to commit updated client changes to:"
type: string
required: true
jobs:
get-all-service-definition:
name: Get all-service definition
runs-on: ubuntu-latest
steps:
- name: Checkout API-Uniform-Contract repo
uses: actions/checkout@v4
with:
token: ${{ secrets.GIT_SECRET }}
repository: Arm-Debug/API-Uniform-Contract
path: API-Uniform-Contract
ref: production
- uses: actions/upload-artifact@master
with:
name: all-service-flat
path: API-Uniform-Contract/all/1/
update-go:
name: Update Go
runs-on: ubuntu-latest
needs: update-client
steps:
- uses: actions/checkout@v4
with:
# So that we have correct GIT_TOKEN to push back to branch as we need workflow permissions
token: ${{ secrets.GIT_SECRET }}
ref: ${{ inputs.branch || github.head_ref || github.ref }}
- name: Checkout Update Go action
uses: actions/checkout@v4
with:
repository: Arm-Debug/update-go-action
ref: refs/tags/latest
token: ${{ secrets.GIT_SECRET }}
persist-credentials: false
path: ./.github/workflows/update-go-action
- name: Update Go
uses: ./.github/workflows/update-go-action
with:
dockerfile: Dockerfile.client
branch: ${{ inputs.branch || github.head_ref || github.ref }}
update-client:
name: Update client
runs-on: ubuntu-latest
needs: get-all-service-definition
steps:
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}
- name: Install continuous-delivery-scripts
run: |
pip install continuous-delivery-scripts
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || github.head_ref || github.ref }}
- name: Download all-service-flat artefact
uses: actions/download-artifact@master
with:
name: all-service-flat
path: all-service-definition
- name: Download openapi-generator
run: |
mkdir -p /usr/local/bin/
curl https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/bin/utils/openapi-generator-cli.sh > /usr/local/bin/openapi-generator
chmod u+x /usr/local/bin/openapi-generator
- name: Clean up previously generated client
run: |
mkdir -p ${{ env.go_module }}
rm -rf ${{ env.go_module }}/*
- name: Generate client
run: |
ls all-service-definition
chmod +x ./scripts/generate-client.sh
./scripts/generate-client.sh -i all-service-definition/all-def-flat.yaml -o ${{ env.go_module }} -d
- name: Copy extensions to client
run: |
if [ -d ./extensions/ ] ; then cp -r extensions/. ${{ env.go_module }}/ ; fi
ls -l ${{ env.go_module }}/*
- name: License files
run: |
cd-license-files
- name: Check for client changes
run: |
SERVER_UPDATE="$(if [[ $(git status ${{ env.go_module }}/* --porcelain | grep -v go.mod | grep -v go.sum) ]] ; then echo '✨ New server autogenerated files' ; fi)"
if [[ $SERVER_UPDATE ]] ; then echo "SERVER_UPDATE=$SERVER_UPDATE" >> $GITHUB_ENV ; fi
- name: Generate News File
if: env.SERVER_UPDATE != ''
run: |
if [[ "${{ env.SERVER_UPDATE }}" ]] ; then cd-create-news-file --type feature "Updated client due to schema changes" ; fi
- name: Commit changes
if: env.SERVER_UPDATE != ''
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: ":sparkles: Automatic changes -> ${{ env.SERVER_UPDATE }} [ci skip]"
file_pattern: ${{ env.go_module }}/* changes/*
commit_user_name: monty-bot
commit_user_email: [email protected]
build-and-test:
name: Build and Test
needs:
- update-go
- update-client
uses: ./.github/workflows/build-and-test.yml
secrets: inherit
with:
branch: ${{ inputs.branch || github.head_ref || github.ref }}
release:
name: Release if necessary
runs-on: ubuntu-latest
needs:
- build-and-test
steps:
- uses: actions/checkout@v4
- name: Trigger release
if: contains(${{ inputs.branch || github.head_ref || github.ref }} , 'main')
run: gh workflow run release.yml -f release_type=release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}