Update SDK #2
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
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@v4 | |
- 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: Node | |
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: typescript-axios | |
config: ./openapi-config.yml | |
- name: Setup Node | |
if: steps.build.outputs.changes | |
uses: actions/setup-node@v4 | |
- 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 }} |