-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SWI-3945: Adding "update-sdk" workflow (#84)
* SWI-3945: Add an update SDK workflow * Update .github/workflows/update-sdk.yml Co-authored-by: Cameron Koegel <[email protected]> --------- Co-authored-by: Cameron Koegel <[email protected]>
- Loading branch information
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
name: Update SDK | ||
|
||
on: | ||
schedule: | ||
- cron: "0 14 * * 2" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update-sdk: | ||
name: Update SDK if Necessary | ||
runs-on: ubuntu-latest | ||
outputs: | ||
generate: ${{ steps.compare.outputs.generate }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Combine Product Specs | ||
uses: Bandwidth/[email protected] | ||
with: | ||
token: ${{ secrets.DX_GITHUB_TOKEN }} | ||
|
||
- name: Determine if a New SDK is Needed | ||
id: compare | ||
run: | | ||
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 | ||
- name: Create JIRA Card for SDK Update | ||
if: ${{ steps.compare.outputs.generate == 'true' }} | ||
id: jira | ||
run: | | ||
JIRA_KEY=$(jq -r '.key' <<< $(curl -s -u $JIRA_USERNAME:$JIRA_TOKEN \ | ||
-X POST https://bandwidth-jira.atlassian.net/rest/api/2/issue \ | ||
-H "Content-Type: application/json" \ | ||
--data-binary @- << EOF | ||
{ | ||
"fields": { | ||
"project": { | ||
"key": "SWI" | ||
}, | ||
"summary": "[$LANGUAGE] Update SDK for New Spec Version", | ||
"description": "Prepare the $LANGUAGE SDK for release based on the latest spec changes.", | ||
"issuetype": { | ||
"name": "Story" | ||
}, | ||
"customfield_12108": "$LANGUAGE SDK is ready for release. Tests are created/updated if need be.", | ||
"customfield_10205": "$EPIC", | ||
"components": [{ | ||
"name": "Client SDKs" | ||
}] | ||
} | ||
} | ||
EOF | ||
)) | ||
echo "jira-key=$JIRA_KEY" >> $GITHUB_OUTPUT | ||
env: | ||
LANGUAGE: C# | ||
EPIC: SWI-1876 | ||
JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }} | ||
JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }} | ||
|
||
- name: Build SDK | ||
id: build | ||
if: ${{ startsWith(steps.jira.outputs.jira-key, 'SWI') }} | ||
uses: Bandwidth/[email protected] | ||
with: | ||
branch-name: ${{ steps.jira.outputs.jira-key }} | ||
token: ${{ secrets.DX_GITHUB_TOKEN }} | ||
openapi-generator-version: 7.1.0 | ||
language: csharp | ||
config: openapi-config.yml | ||
|
||
|
||
- name: Open Pull Request | ||
if: steps.build.outputs.changes | ||
run: | | ||
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' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }} | ||
|
||
notify-for-failures: | ||
name: Notify for Failures | ||
needs: [update-sdk] | ||
if: failure() | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Notify Slack of Failures | ||
uses: Bandwidth/[email protected] | ||
with: | ||
job-status: failure | ||
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} | ||
slack-channel: ${{ secrets.SLACK_CHANNEL }} |