[Merged by Bors] - fix: rewrite update_dependencies_zulip action #47408
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: Add "ready-to-merge" and "delegated" label from comment | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
add_ready_to_merge_label: | |
name: Add ready-to-merge label | |
if: (toJSON(github.event.issue.pull_request) != 'null') && (startsWith(github.event.comment.body, 'bors r+') || contains(toJSON(github.event.comment.body), '\r\nbors r+') || startsWith(github.event.comment.body, 'bors merge') || contains(toJSON(github.event.comment.body), '\r\nbors merge')) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: octokit/[email protected] | |
name: Get PR head | |
id: get_pr_head | |
with: | |
route: GET /repos/:repository/pulls/:pull_number | |
repository: ${{ github.repository }} | |
pull_number: ${{ github.event.issue.number }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Parse steps.get_pr_head.outputs.data, since it is a string | |
- id: parse_pr_head | |
name: Parse PR head | |
uses: gr2m/[email protected] | |
with: | |
json: ${{ steps.get_pr_head.outputs.data }} | |
head_user: 'head.user.login' | |
# we skip the rest if this PR is from a fork, | |
# since the GITHUB_TOKEN doesn't have write perms | |
- if: steps.parse_pr_head.outputs.head_user == 'leanprover-community' | |
uses: octokit/[email protected] | |
name: Get comment author | |
id: get_user | |
with: | |
route: GET /repos/:repository/collaborators/:username/permission | |
repository: ${{ github.repository }} | |
username: ${{ github.event.comment.user.login }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Parse steps.get_user.outputs.data, since it is a string | |
- if: steps.parse_pr_head.outputs.head_user == 'leanprover-community' | |
id: parse_user | |
name: Parse comment author permission | |
uses: gr2m/[email protected] | |
with: | |
json: ${{ steps.get_user.outputs.data }} | |
permission: 'permission' | |
- if: (steps.parse_pr_head.outputs.head_user == 'leanprover-community') && (steps.parse_user.outputs.permission == 'admin') | |
uses: octokit/[email protected] | |
id: add_label | |
name: Add label | |
with: | |
route: POST /repos/:repository/issues/:issue_number/labels | |
repository: ${{ github.repository }} | |
issue_number: ${{ github.event.issue.number }} | |
labels: '["ready-to-merge"]' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- if: (steps.parse_pr_head.outputs.head_user == 'leanprover-community') && (steps.parse_user.outputs.permission == 'admin') | |
id: remove_labels | |
name: Remove "awaiting-review" and "awaiting-author" | |
# we use curl rather than octokit/request-action so that the job won't fail | |
# (and send an annoying email) if the labels don't exist | |
run: | | |
curl --request DELETE \ | |
--url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels/awaiting-review \ | |
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | |
curl --request DELETE \ | |
--url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels/awaiting-author \ | |
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | |
add_delegated_label: | |
name: Add delegated label | |
if: (toJSON(github.event.issue.pull_request) != 'null') && (startsWith(github.event.comment.body, 'bors d') || contains(toJSON(github.event.comment.body), '\r\nbors d')) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: octokit/[email protected] | |
name: Get PR head | |
id: get_pr_head | |
with: | |
route: GET /repos/:repository/pulls/:pull_number | |
repository: ${{ github.repository }} | |
pull_number: ${{ github.event.issue.number }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Parse steps.get_pr_head.outputs.data, since it is a string | |
- id: parse_pr_head | |
name: Parse PR head | |
uses: gr2m/[email protected] | |
with: | |
json: ${{ steps.get_pr_head.outputs.data }} | |
head_user: 'head.user.login' | |
# we skip the rest if this PR is from a fork, | |
# since the GITHUB_TOKEN doesn't have write perms | |
- if: steps.parse_pr_head.outputs.head_user == 'leanprover-community' | |
uses: octokit/[email protected] | |
name: Get comment author | |
id: get_user | |
with: | |
route: GET /repos/:repository/collaborators/:username/permission | |
repository: ${{ github.repository }} | |
username: ${{ github.event.comment.user.login }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Parse steps.get_user.outputs.data, since it is a string | |
- if: steps.parse_pr_head.outputs.head_user == 'leanprover-community' | |
id: parse_user | |
name: Parse comment author permission | |
uses: gr2m/[email protected] | |
with: | |
json: ${{ steps.get_user.outputs.data }} | |
permission: 'permission' | |
- if: (steps.parse_pr_head.outputs.head_user == 'leanprover-community') && (steps.parse_user.outputs.permission == 'admin') | |
uses: octokit/[email protected] | |
id: add_label | |
name: Add label | |
with: | |
route: POST /repos/:repository/issues/:issue_number/labels | |
repository: ${{ github.repository }} | |
issue_number: ${{ github.event.issue.number }} | |
labels: '["delegated"]' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- if: (steps.parse_pr_head.outputs.head_user == 'leanprover-community') && (steps.parse_user.outputs.permission == 'admin') | |
id: remove_labels | |
name: Remove "awaiting-review" | |
# we use curl rather than octokit/request-action so that the job won't fail | |
# (and send an annoying email) if the labels don't exist | |
run: | | |
curl --request DELETE \ | |
--url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels/awaiting-review \ | |
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' |