Skip to content

Commit c9c92a3

Browse files
committed
SWI-3348 Add update-sdk workflow
1 parent 5e687ae commit c9c92a3

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

.github/workflows/update-sdk.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Update SDK
2+
3+
on:
4+
schedule:
5+
- cron: "0 14 * * 2"
6+
workflow_dispatch:
7+
8+
jobs:
9+
update-sdk:
10+
name: Update SDK if Necessary
11+
runs-on: ${{ fromJSON(vars.SWI_GLORG_UBUNTU_2204) }}
12+
outputs:
13+
generate: ${{ steps.compare.outputs.generate }}
14+
permissions:
15+
id-token: write
16+
contents: write
17+
steps:
18+
- name: Get Github and Jira Tokens from Vault
19+
uses: Bandwidth/vault-provider-action@v1
20+
with:
21+
secrets: |
22+
workloads/prod/software_infra::secrets:dx-github-token:dx-github-token@1::DX_GITHUB_TOKEN
23+
workloads/prod/software_infra::secrets:SDLC-Enforcer-Prod:JIRA_TOKEN@9::JIRA_TOKEN
24+
workloads/prod/software_infra::secrets:SDLC-Enforcer-Prod:JIRA_USERNAME@9::JIRA_USERNAME
25+
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
29+
- name: Combine Product Specs
30+
uses: Bandwidth/[email protected]
31+
with:
32+
token: ${{ env.DX_GITHUB_TOKEN }}
33+
34+
- name: Determine if a New SDK is Needed
35+
id: compare
36+
run: |
37+
if cmp -s "bandwidth.yml" "api-specs/bandwidth.yml"; then :; else mv -f api-specs/bandwidth.yml bandwidth.yml; rm -r -f api-specs; echo "generate=true" >> $GITHUB_OUTPUT; fi
38+
39+
- name: Create JIRA Card for SDK Update
40+
if: ${{ steps.compare.outputs.generate == 'true' }}
41+
id: jira
42+
run: |
43+
JIRA_KEY=$(jq -r '.key' <<< $(curl -s -u $JIRA_USERNAME:$JIRA_TOKEN \
44+
-X POST https://bandwidth-jira.atlassian.net/rest/api/2/issue \
45+
-H "Content-Type: application/json" \
46+
--data-binary @- << EOF
47+
{
48+
"fields": {
49+
"project": {
50+
"key": "SWI"
51+
},
52+
"summary": "[$LANGUAGE] Update SDK for New Spec Version",
53+
"description": "Prepare the $LANGUAGE SDK for release based on the latest spec changes.",
54+
"issuetype": {
55+
"name": "Story"
56+
},
57+
"customfield_12108": "$LANGUAGE SDK is ready for release. Tests are created/updated if need be.",
58+
"customfield_10205": "$EPIC",
59+
"components": [{
60+
"name": "Client SDKs"
61+
}]
62+
}
63+
}
64+
EOF
65+
))
66+
echo "jira-key=$JIRA_KEY" >> $GITHUB_OUTPUT
67+
env:
68+
LANGUAGE: Java
69+
EPIC: SWI-1876
70+
71+
- name: Build SDK
72+
id: build
73+
if: ${{ startsWith(steps.jira.outputs.jira-key, 'SWI') }}
74+
uses: Bandwidth/[email protected]
75+
with:
76+
branch-name: ${{ steps.jira.outputs.jira-key }}
77+
token: ${{ env.DX_GITHUB_TOKEN }}
78+
openapi-generator-version: 7.0.0
79+
language: java
80+
config: ./openapi-config.yml
81+
82+
- name: Setup Java
83+
if: steps.build.outputs.changes
84+
uses: actions/setup-java@v3
85+
with:
86+
java-version: 17
87+
88+
- name: Clean SDK
89+
if: steps.build.outputs.changes
90+
run: |
91+
mvn clean
92+
93+
- name: Open Pull Request
94+
if: steps.build.outputs.changes
95+
run: |
96+
gh pr create -B main -H Bandwidth:${{ steps.jira.outputs.jira-key }} -t '${{ steps.jira.outputs.jira-key }} Update SDK Based on Recent Spec Changes' -b 'Auto-generated by Update SDK Workflow'
97+
env:
98+
GITHUB_TOKEN: ${{ env.DX_GITHUB_TOKEN }}
99+
100+
notify_for_failures:
101+
name: Notify for Failures
102+
needs: [update-sdk]
103+
if: failure()
104+
runs-on: ubuntu-latest
105+
steps:
106+
- name: Notify Slack of Failures
107+
uses: Bandwidth/[email protected]
108+
with:
109+
job-status: failure
110+
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
111+
slack-channel: ${{ secrets.SLACK_CHANNEL }}

0 commit comments

Comments
 (0)