Skip to content

Commit 6289f10

Browse files
Merge pull request opendatahub-io#84 from harshad16/fix-pr-wf
GH Action: Use push event instead of pull request
2 parents 7c51005 + 5fc3a61 commit 6289f10

File tree

2 files changed

+52
-29
lines changed

2 files changed

+52
-29
lines changed

.github/workflows/pr-close-image-delete.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Delete quay image of PR once merged
2+
on:
3+
push:
4+
branches:
5+
- 'main'
6+
7+
permissions:
8+
pull-requests: read
9+
env:
10+
QUAY_IMAGE_REPO: ${{ secrets.QUAY_IMAGE_REPO }}
11+
jobs:
12+
delete-pr-quay-image:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Git checkout
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: '0'
19+
- name: Install skopeo
20+
shell: bash
21+
run: |
22+
sudo apt-get -y update
23+
sudo apt-get -y install skopeo
24+
- name: Get Pull Request Number
25+
uses: actions/github-script@v6
26+
id: get_issue_number
27+
with:
28+
script: |
29+
if (context.issue.number) {
30+
// Return issue number if present
31+
return context.issue.number;
32+
} else {
33+
// Otherwise return issue number from commit
34+
return (
35+
await github.rest.repos.listPullRequestsAssociatedWithCommit({
36+
commit_sha: context.sha,
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
})
40+
).data[0].number;
41+
}
42+
result-encoding: string
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
- name: Delete PR image
46+
shell: bash
47+
env:
48+
PR: ${{steps.get_issue_number.outputs.result}}
49+
QUAY_ROBOT_USERNAME: ${{ secrets.QUAY_ROBOT_USERNAME }}
50+
QUAY_ROBOT_TOKEN: ${{ secrets.QUAY_ROBOT_TOKEN }}
51+
run: |
52+
skopeo delete --creds ${QUAY_ROBOT_USERNAME}:${QUAY_ROBOT_TOKEN} docker://${QUAY_IMAGE_REPO}:pr-${{ env.PR }}

0 commit comments

Comments
 (0)