Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: delete the branch once cleanup is completed #118

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ jobs:
if: '${{ needs.review_status.outputs.REVIEW_DECISION == ''APPROVED'' }}'
runs-on: 'ubuntu-latest'
permissions:
contents: 'read'
# Required for closing a branch, see ref: https://docs.github.com/en/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#repository-permissions-for-contents
contents: 'write'
id-token: 'write'
pull-requests: 'write'
name: 'Handle AOD Request Cleanup'
Expand Down Expand Up @@ -282,3 +283,16 @@ jobs:
issue_number: ${{ github.event.pull_request.number }},
body: `**\`Access on Demand\`** - 🟦 **\`IAM\`** request not found, skip cleanup.`,
});
- name: 'Delete Branch'
# Only delete branch when cleanups are skipped or successfully handled.
if: '${{ always() && steps.cleanup_iam.outcome != ''failure'' && steps.cleanup_tool.outcome != ''failure'' }}'
uses: 'actions/github-script@98814c53be79b1d30f795b907e553d8679345975' # ratchet:actions/github-script@v6
with:
github-token: '${{ github.token }}'
retries: '3'
script: |+
await github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `heads/${{ github.event.pull_request.head.ref }}`,
});
6 changes: 4 additions & 2 deletions .github/workflows/note.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ env:
⛔️ <strong>This is an AOD request, and merging is NOT allowed.</strong>
The request will be automatically applied once the code owners approve it.
Please close the PR once you are finished or it will automatically be closed
after ~${{ inputs.expiry_hours }} hours of it's last update. For more
instructions, please see [here](${{ inputs.aod_instruction_link }}).
after ~${{ inputs.expiry_hours }} hours of it's last update. Please
<strong>DO NOT</strong> delete the branch manually, the branch will be
automatically deleted once PR is closed. For more instructions, please see
[here](${{ inputs.aod_instruction_link }}).

jobs:
note:
Expand Down