File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 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 }}." }'
You can’t perform that action at this time.
0 commit comments