chore(deps): update docker/login-action digest to 5e57cd1 (main) #21
This file contains hidden or 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: Clean PR Branch | |
| on: | |
| pull_request: | |
| types: [closed] | |
| jobs: | |
| cleanup: | |
| runs-on: ubuntu-latest | |
| if: contains(github.event.pull_request.labels.*.name, 'status/auto-created') | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Check PR branch exists | |
| id: check-branch | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| with: | |
| script: | | |
| try { | |
| let {status: status} = await github.rest.git.getRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: "heads/${{ github.event.pull_request.head.ref }}" | |
| }) | |
| if (status == 200) { | |
| await core.summary | |
| .addHeading("PR Branch Found", 2) | |
| .addRaw("The PR branch was found and will be cleaned up.") | |
| .write(); | |
| } else { | |
| core.setFailed("Branch not found, nothing to clean. (failure can be ignored)"); | |
| } | |
| } | |
| catch (err) { | |
| if (err.response && err.response.status === 404) { | |
| await core.summary | |
| .addHeading("PR Branch Not Found", 2) | |
| .addRaw("The PR branch didn't exist; the action failure can be ignored.") | |
| .write(); | |
| core.setFailed("Branch not found, nothing to clean. (failure can be ignored)"); | |
| } else { | |
| core.setFailed(`Action failed with error ${err}`); | |
| } | |
| } | |
| - name: Delete the PR branch | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| with: | |
| script: | | |
| try { | |
| let {status: status} = github.rest.git.deleteRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: "heads/${{ github.event.pull_request.head.ref }}" | |
| }) | |
| await core.summary | |
| .addHeading("PR Branch Deleted", 2) | |
| .addRaw("The PR's branch `${{ github.event.pull_request.head.ref }}` was deleted.") | |
| .write(); | |
| } | |
| catch (err) { | |
| // setFailed logs the message and sets a failing exit code | |
| core.setFailed(`Action failed with error ${err}`); | |
| } |