Update API #178
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 API | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "15 23 * * *" | |
jobs: | |
update-api: | |
if: ${{ github.repository == 'slack-ruby/slack-ruby-client' }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Config git to rebase | |
run: git config --global pull.rebase true | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "3.2" | |
bundler-cache: true | |
- name: Update API from slack-api-ref | |
run: bundle exec rake slack:api:update | |
- name: Remove files added by setup-ruby | |
run: rm -rf vendor | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" | |
- name: Get slack-api-ref ref | |
id: api-ref | |
run: echo "::set-output name=api-ref::$(git rev-parse --short HEAD:lib/slack/web/api/slack-api-ref)" | |
- name: GitHub App token | |
if: ${{ github.repository == 'slack-ruby/slack-ruby-client' }} | |
id: github_app_token | |
uses: tibdex/[email protected] | |
with: | |
app_id: ${{ secrets.CI_APP_ID }} | |
private_key: ${{ secrets.CI_APP_PRIVATE_KEY }} | |
installation_id: 36985419 | |
- name: Create pull request | |
id: cpr | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: Update API from slack-api-ref@${{ steps.api-ref.outputs.api-ref }} (${{ steps.date.outputs.date }}) | |
title: Update API from slack-api-ref@${{ steps.api-ref.outputs.api-ref }} | |
body: | | |
Update API from [slack-api-ref](https://github.com/slack-ruby/slack-api-ref). | |
Rev: ${{ steps.api-ref.outputs.api-ref }} | |
Date: ${{ steps.date.outputs.date }} | |
branch: automated-api-update | |
base: master | |
committer: slack-ruby-ci-bot <[email protected]> | |
author: slack-ruby-ci-bot <[email protected]> | |
- name: Update CHANGELOG | |
uses: jacobtomlinson/gha-find-replace@v3 | |
if: ${{ steps.cpr.outputs.pull-request-number != '' }} | |
with: | |
include: CHANGELOG.md | |
find: "\\* Your contribution here." | |
replace: "* [#${{steps.cpr.outputs.pull-request-number}}](https://github.com/slack-ruby-client/pulls/${{steps.cpr.outputs.pull-request-number}}): Update API from [slack-api-ref@${{ steps.api-ref.outputs.api-ref }}](https://github.com/slack-ruby/slack-api-ref/commit/${{ steps.api-ref.outputs.api-ref }}) - [@slack-ruby-ci-bot](https://github.com/apps/slack-ruby-ci-bot).\n* Your contribution here." | |
- name: Commit and Push | |
if: ${{ steps.cpr.outputs.pull-request-number != '' }} | |
run: | | |
git config --local user.name 'slack-ruby-ci-bot' | |
git config --local user.email '[email protected]' | |
git config --local --unset-all http.https://github.com/.extraheader || true | |
AUTH=$(echo -n "x-access-token:${{ steps.github_app_token.outputs.token || secrets.GITHUB_TOKEN }}" | base64) | |
echo "::add-mask::${AUTH}" | |
git config --local http.https://github.com/.extraheader "AUTHORIZATION: basic ${AUTH}" | |
git add CHANGELOG.md | |
git commit --amend --no-edit | |
git push origin automated-api-update -f |