|
| 1 | +name: Update API from slack-api-ref |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + - cron: "15 23 * * *" |
| 5 | +jobs: |
| 6 | + update-api: |
| 7 | + if: ${{ github.repository == 'slack-ruby/slack-ruby-client' }} |
| 8 | + runs-on: ubuntu-latest |
| 9 | + permissions: |
| 10 | + contents: write |
| 11 | + pull-requests: write |
| 12 | + steps: |
| 13 | + # Setup and potential creation of initial pull request |
| 14 | + - uses: actions/checkout@v3 |
| 15 | + with: |
| 16 | + submodules: recursive |
| 17 | + - name: Get current date |
| 18 | + run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV |
| 19 | + - name: Make a file to trigger an initial pull request |
| 20 | + run : echo "${{ env.CURRENT_DATE }}" > file.txt |
| 21 | + - name: Create initial pull request |
| 22 | + id: create-initial-pull-request |
| 23 | + uses: peter-evans/create-pull-request@v4 |
| 24 | + with: |
| 25 | + branch: automated-api-update |
| 26 | + base: master |
| 27 | + # Generation of new API methods and update of pull request |
| 28 | + - name: Set up Ruby |
| 29 | + uses: ruby/setup-ruby@v1 |
| 30 | + with: |
| 31 | + ruby-version: "3.2" |
| 32 | + bundler-cache: true |
| 33 | + - name: Update API from slack-api-ref |
| 34 | + run: bundle exec rake slack:api:update |
| 35 | + - name: Remove files added by setup-ruby |
| 36 | + run: rm -rf vendor |
| 37 | + - name: Update changelog |
| 38 | + run: | |
| 39 | + ruby -i -pe 'sub(/\* Your contribution here\./, "* Your contribution here.\n* [#${{ steps.create-initial-pull-request.outputs.pull-request-number }}](https://github.com/slack-ruby/slack-ruby-client/pull/${{ steps.create-initial-pull-request.outputs.pull-request-number }}): Update Slack API (${{ env.CURRENT_DATE }}) - [@slack-ruby-client](https://github.com/slack-ruby/slack-ruby-client).")' CHANGELOG.md |
| 40 | + - name: Create pull request with changelog |
| 41 | + id: update-changelog |
| 42 | + uses: peter-evans/create-pull-request@v4 |
| 43 | + with: |
| 44 | + commit-message: Update API from slack-api-ref (${{ env.CURRENT_DATE }}) |
| 45 | + title: Update API from slack-api-ref (${{ env.CURRENT_DATE }}) |
| 46 | + body: | |
| 47 | + Update API from [slack-api-ref](https://github.com/slack-ruby/slack-api-ref) (${{ env.CURRENT_DATE }}) |
| 48 | + branch: automated-api-update |
| 49 | + base: master |
| 50 | + committer: GitHub <[email protected]> |
| 51 | + author: GitHub <[email protected]> |
0 commit comments