Skip to content

Commit f04847d

Browse files
authored
[2.18] On PR merge update the quay image (#205)
1 parent affbc1d commit f04847d

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
name: Build and Push Container Image On PR Merge
3+
4+
on:
5+
pull_request_target:
6+
types: [closed]
7+
8+
permissions:
9+
pull-requests: write
10+
contents: write
11+
issues: write
12+
13+
jobs:
14+
if_merged:
15+
if: github.event.pull_request.merged == true
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout Repository
19+
uses: actions/checkout@v4
20+
- name: Set env TAG
21+
run: |
22+
if [ ${{ github.event.pull_request.base.ref }} == "main" ]; then
23+
echo "TAG=latest" >> $GITHUB_ENV
24+
else
25+
echo "TAG=${{ github.event.pull_request.base.ref }}" >> "$GITHUB_ENV"
26+
fi
27+
- name: Build Image
28+
id: build-image
29+
uses: redhat-actions/buildah-build@v2
30+
with:
31+
image: opendatahub-tests
32+
tags: ${{ env.TAG }}
33+
containerfiles: |
34+
./Dockerfile
35+
36+
- name: Push To Image Registry
37+
id: push-to-registry
38+
uses: redhat-actions/push-to-registry@v2
39+
with:
40+
image: ${{ steps.build-image.outputs.image }}
41+
tags: ${{ steps.build-image.outputs.tags }}
42+
registry: quay.io/opendatahub
43+
username: ${{ secrets.QUAY_USERNAME }}
44+
password: ${{ secrets.QUAY_PASSWORD }}
45+
46+
- name: Add comment to PR
47+
if: always()
48+
env:
49+
URL: ${{ github.event.pull_request.comments_url }}
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
run: |
52+
curl \
53+
-X POST \
54+
$URL \
55+
-H "Content-Type: application/json" \
56+
-H "Authorization: token $GITHUB_TOKEN" \
57+
--data '{ "body": "Status of building tag ${{ env.TAG }}: ${{ steps.build-image.outcome }}. \nStatus of pushing tag ${{ env.TAG }} to image registry: ${{ steps.push-to-registry.outcome }}." }'

0 commit comments

Comments
 (0)