|
| 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: ubuntu-latest |
| 12 | + outputs: |
| 13 | + generate: ${{ steps.compare.outputs.generate }} |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v3 |
| 17 | + |
| 18 | + - name: Combine Product Specs |
| 19 | + |
| 20 | + with: |
| 21 | + token: ${{ secrets.DX_GITHUB_TOKEN }} |
| 22 | + |
| 23 | + - name: Determine if a New SDK is Needed |
| 24 | + id: compare |
| 25 | + run: | |
| 26 | + 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 |
| 27 | +
|
| 28 | + - name: Create JIRA Card for SDK Update |
| 29 | + if: ${{ steps.compare.outputs.generate == 'true' }} |
| 30 | + id: jira |
| 31 | + run: | |
| 32 | + JIRA_KEY=$(jq -r '.key' <<< $(curl -s -u $JIRA_USERNAME:$JIRA_TOKEN \ |
| 33 | + -X POST https://bandwidth-jira.atlassian.net/rest/api/2/issue \ |
| 34 | + -H "Content-Type: application/json" \ |
| 35 | + --data-binary @- << EOF |
| 36 | + { |
| 37 | + "fields": { |
| 38 | + "project": { |
| 39 | + "key": "SWI" |
| 40 | + }, |
| 41 | + "summary": "[$LANGUAGE] Update SDK for New Spec Version", |
| 42 | + "description": "Prepare the $LANGUAGE SDK for release based on the latest spec changes.", |
| 43 | + "issuetype": { |
| 44 | + "name": "Story" |
| 45 | + }, |
| 46 | + "customfield_12108": "$LANGUAGE SDK is ready for release. Tests are created/updated if need be.", |
| 47 | + "customfield_10205": "$EPIC", |
| 48 | + "components": [{ |
| 49 | + "name": "Client SDKs" |
| 50 | + }] |
| 51 | + } |
| 52 | + } |
| 53 | + EOF |
| 54 | + )) |
| 55 | + echo "jira-key=$JIRA_KEY" >> $GITHUB_OUTPUT |
| 56 | + env: |
| 57 | + LANGUAGE: Java |
| 58 | + EPIC: SWI-1876 |
| 59 | + JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }} |
| 60 | + JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }} |
| 61 | + |
| 62 | + - name: Build SDK |
| 63 | + id: build |
| 64 | + if: ${{ startsWith(steps.jira.outputs.jira-key, 'SWI') }} |
| 65 | + |
| 66 | + with: |
| 67 | + branch-name: ${{ steps.jira.outputs.jira-key }} |
| 68 | + token: ${{ secrets.DX_GITHUB_TOKEN }} |
| 69 | + openapi-generator-version: 7.0.0 |
| 70 | + language: java |
| 71 | + config: ./openapi-config.yml |
| 72 | + |
| 73 | + - name: Setup Java |
| 74 | + if: steps.build.outputs.changes |
| 75 | + uses: actions/setup-java@v3 |
| 76 | + with: |
| 77 | + java-version: 17 |
| 78 | + |
| 79 | + - name: Clean SDK |
| 80 | + if: steps.build.outputs.changes |
| 81 | + run: | |
| 82 | + mvn clean |
| 83 | +
|
| 84 | + - name: Open Pull Request |
| 85 | + if: steps.build.outputs.changes |
| 86 | + run: | |
| 87 | + 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' |
| 88 | + env: |
| 89 | + GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }} |
| 90 | + |
| 91 | + notify_for_failures: |
| 92 | + name: Notify for Failures |
| 93 | + needs: [update-sdk] |
| 94 | + if: failure() |
| 95 | + runs-on: ubuntu-latest |
| 96 | + steps: |
| 97 | + - name: Notify Slack of Failures |
| 98 | + |
| 99 | + with: |
| 100 | + job-status: failure |
| 101 | + slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} |
| 102 | + slack-channel: ${{ secrets.SLACK_CHANNEL }} |
0 commit comments