-
-
Notifications
You must be signed in to change notification settings - Fork 226
79 lines (79 loc) · 3.51 KB
/
update_api.yml
File metadata and controls
79 lines (79 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Update API
on:
workflow_dispatch:
schedule:
- cron: "15 23 * * 1"
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@v6
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 "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Get slack-api-ref ref
id: api-ref
run: echo "api-ref=$(git rev-parse --short HEAD:lib/slack/web/api/slack-api-ref)" >> $GITHUB_OUTPUT
- name: GitHub App token
if: ${{ github.repository == 'slack-ruby/slack-ruby-client' }}
id: github_app_token
uses: tibdex/github-app-token@v2.1.0
with:
app_id: ${{ secrets.CI_APP_ID }}
private_key: ${{ secrets.CI_APP_PRIVATE_KEY }}
installation_retrieval_mode: id
installation_retrieval_payload: 36985419
- name: Create pull request
id: cpr
uses: peter-evans/create-pull-request@v8
with:
token: ${{ steps.github_app_token.outputs.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 <noreply@github.com>
author: slack-ruby-ci-bot <noreply@github.com>
- name: Check out update branch
if: ${{ steps.cpr.outputs.pull-request-number != '' }}
run: |
git fetch origin automated-api-update
git checkout automated-api-update
- 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/slack-ruby-client/pull/${{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 'noreply@github.com'
git add CHANGELOG.md
git commit --amend --no-edit
git remote set-url origin https://x-access-token:${{ steps.github_app_token.outputs.token || secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git push origin automated-api-update -f