Skip to content

Commit 68e6dd1

Browse files
On PR merge update the quay image (#189) (#253)
updates! 39c5869 updates! a28b878 updates! f56e606 Co-authored-by: Debarati Basu-Nag <dbasunag@redhat.com>
1 parent 735b461 commit 68e6dd1

File tree

1 file changed

+56
-0
lines changed

1 file changed

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