Skip to content

Update SDK

Update SDK #4

Workflow file for this run

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/api-specs-combine-action@v1.0.0
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: Java
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/generate-sdk-action@v3.0.0
with:
branch-name: ${{ steps.jira.outputs.jira-key }}
token: ${{ secrets.DX_GITHUB_TOKEN }}
openapi-generator-version: 7.0.0
language: java
config: ./openapi-config.yml
- name: Setup Java
if: steps.build.outputs.changes
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- name: Clean SDK
if: steps.build.outputs.changes
run: |
mvn clean
- 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/build-notify-slack-action@v1.0.0
with:
job-status: failure
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
slack-channel: ${{ secrets.SLACK_CHANNEL }}