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