From 146ea6812e03cbb86a4bb1d186b3c8da4da7ebc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Wed, 20 Sep 2023 19:52:47 +0900 Subject: [PATCH] feat(workflow): add job close-pr in pull.yml --- .github/workflows/pull.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index c3debcbb..de384059 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -1,6 +1,33 @@ name: PullLint on: [ pull_request ] jobs: + # This workflow closes invalid PR + close-pr: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + - name: Setup GitHub CLI + uses: cli/cli@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + # Runs a single command using the runners shell + - name: Get PR commit message + id: pr + run: echo "::set-output name=message::$(git log --format=%B -n 1)" + + # Runs a set of commands using the runners shell + - name: Close PR if commit message is "Update main.go" + if: steps.pr.outputs.message == 'Update main.go' + run: | + echo "Closing this PR because commit message is 'Update main.go'" + gh pr close ${{ github.event.pull_request.number }} --delete-branch + golangci: name: lint runs-on: ubuntu-latest