Manage Approved Label #6
Workflow file for this run
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: Manage Approved Label | |
on: | |
pull_request_review: | |
types: [submitted] | |
jobs: | |
approval-label: | |
runs-on: ubuntu-latest | |
name: Approval Label | |
steps: | |
- name: Sudo GitHub Token | |
id: sudo_github_token | |
uses: tibdex/[email protected] | |
with: | |
app_id: ${{vars.SUDO_GHA_APP_ID}} | |
installation_id: ${{vars.SUDO_GHA_APP_INSTALLATION_ID}} | |
private_key: ${{secrets.SUDO_GHA_APP_PRIVATE_KEY}} | |
- name: Get pr info | |
uses: octokit/[email protected] | |
id: get_pr_info | |
with: | |
variables: | | |
owner: "Scalr" | |
repo: ${{github.event.repository.name}} | |
pr: ${{github.event.pull_request.number}} | |
query: | | |
query ($owner: String!, $repo: String!, $pr: Int!) { | |
repository(owner: $owner, name: $repo) { | |
pullRequest(number: $pr) { | |
reviewDecision | |
timelineItems(last: 250) { | |
edges { | |
node { | |
__typename | |
} | |
} | |
} | |
} | |
} | |
} | |
env: | |
GITHUB_TOKEN: ${{steps.sudo_github_token.outputs.token}} | |
- name: Set label | |
if: github.event.review.state == 'approved' && fromJson(steps.get_pr_info.outputs.data).repository.pullRequest.reviewDecision == 'APPROVED' | |
uses: actions-ecosystem/action-add-labels@v1 | |
with: | |
labels: approved | |
github_token: ${{steps.sudo_github_token.outputs.token}} | |
- name: Remove label | |
if: github.event.review.state != 'approved' || fromJson(steps.get_pr_info.outputs.data).repository.pullRequest.reviewDecision != 'APPROVED' | |
uses: actions-ecosystem/action-remove-labels@v1 | |
with: | |
labels: approved | |
github_token: ${{steps.sudo_github_token.outputs.token}} |