[workflow] Update functions.json #16
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: Auto Approve and Merge | |
on: | |
pull_request: | |
types: [opened] | |
workflow_dispatch: | |
jobs: | |
auto-approve-and-merge: | |
runs-on: ubuntu-latest | |
outputs: | |
is_aoijsbot: ${{ steps.check_user.outputs.is_aoijsbot }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Check if the PR is opened by aoijsbot | |
id: check_user | |
run: | | |
if [ "${{ github.actor }}" == "aoijsbot" ]; then | |
echo "Is opened by aoijsbot." | |
echo "::set-output name=is_aoijsbot::true" | |
else | |
echo "Not opened by aoijsbot, skipping." | |
echo "::set-output name=is_aoijsbot::false" | |
fi | |
continue-on-error: true | |
- name: Notify Discord about PR opened | |
if: steps.check_user.outputs.is_aoijsbot == 'true' | |
run: | | |
curl -X POST \ | |
-H "Content-Type: application/json" \ | |
-d "{\"content\": \"A pull request was opened by ${GITHUB_ACTOR}.\"}" \ | |
${{ secrets.DISCORD_TOKEN }} | |
- name: Sleep | |
if: steps.check_user.outputs.is_aoijsbot == 'true' | |
run: | | |
echo "Waiting 30 seconds for check to complete" | |
sleep 30 | |
- name: GitHub Checks | |
uses: poseidon/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Approve the pull request | |
if: steps.check_user.outputs.is_aoijsbot == 'true' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh pr review ${{ github.event.pull_request.number }} --approve | |
- name: Merge the pull request | |
if: steps.check_user.outputs.is_aoijsbot == 'true' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh pr merge ${{ github.event.pull_request.number }} --squash --admin | |
- name: Delete branch after merge | |
if: steps.check_user.outputs.is_aoijsbot == 'true' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
BRANCH_NAME=${{ github.event.pull_request.head.ref }} | |
gh api -X DELETE "repos/${{ github.repository }}/git/refs/heads/$BRANCH_NAME" | |
- name: Notify Discord about success | |
if: steps.check_user.outputs.is_aoijsbot == 'true' | |
run: | | |
curl -X POST \ | |
-H "Content-Type: application/json" \ | |
-d "{\"content\": \"Pull request #${{ github.event.pull_request.number }} by aoijsbot has been successfully approved and merged.\"}" \ | |
${{ secrets.DISCORD_TOKEN }} | |
- name: Notify Discord about failure | |
if: steps.check_user.outputs.is_aoijsbot == 'true' && failure() | |
run: | | |
curl -X POST \ | |
-H "Content-Type: application/json" \ | |
-d "{\"content\": \"Pull request #${{ github.event.pull_request.number }} by aoijsbot failed to be approved or merged.\"}" \ | |
${{ secrets.DISCORD_TOKEN }} |