Skip to content

Commit

Permalink
test cleanup and expire
Browse files Browse the repository at this point in the history
  • Loading branch information
sqin2019 committed Sep 11, 2023
1 parent 11451d1 commit 97aab50
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/expire.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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: |-
Expand Down Expand Up @@ -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,
Expand All @@ -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;

0 comments on commit 97aab50

Please sign in to comment.