From 97aab5023d700da2b4f3292d37de479b05fa6b58 Mon Sep 17 00:00:00 2001 From: Suhong Qin Date: Mon, 11 Sep 2023 11:53:31 -0700 Subject: [PATCH] test cleanup and expire --- .github/workflows/expire.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/expire.yml b/.github/workflows/expire.yml index 65cf7c3..fdf79ae 100644 --- a/.github/workflows/expire.yml +++ b/.github/workflows/expire.yml @@ -29,7 +29,7 @@ on: required: false outputs: pulls: - description: "Information of the pull requests that are expired." + description: 'Information of the pull requests that are expired and closed.' value: '${{ jobs.expire.outputs.pulls }}' permissions: @@ -40,13 +40,13 @@ jobs: expire: runs-on: 'ubuntu-latest' outputs: - pulls: '${{ steps.close_pr.outputs.result }}' + pulls: '${{ steps.expire_pr.outputs.result }}' steps: - - id: close_pr + - id: 'expire_pr' uses: 'actions/github-script@98814c53be79b1d30f795b907e553d8679345975' # ratchet:actions/github-script@v6 with: - # Token required for authentication when deleting a branch, see - # JavaScript example in ref: https://docs.github.com/en/rest/git/refs?apiVersion=2022-11-28#delete-a-reference + # Token required for authentication when getting a branch, see + # JavaScript example in ref: https://docs.github.com/en/rest/git/refs?apiVersion=2022-11-28#get-a-reference github-token: '${{ github.token }}' retries: 3 script: |- @@ -102,6 +102,13 @@ jobs: core.info(`Closing #${pull['number']} (${pull['title']})`); + await github.rest.pulls.update({ + owner: repoOwner, + repo: repoName, + pull_number: pull['number'], + state: 'closed', + }); + // Comment on closed PRs. await github.rest.issues.createComment({ owner: repoOwner, @@ -110,13 +117,10 @@ jobs: body: `**\`Access on Demand\`** - request closed and branch deleted due to inactivity (no new commit) for at least ${{ inputs.expiry_hours }} hours`, }); - core.info(`pull ${pull}`); expiredPulls.push({pullNumber: pull['number'], pullBranch: pull['head']['ref']}) - core.info(`expiredPull ${expiredPulls}`); } else { core.info(`Skipping #${pull['number']} (${pull['title']}) - not an AOD request`); } })); - core.info(`outter expiredPull ${expiredPulls}`); return expiredPulls;