-
Notifications
You must be signed in to change notification settings - Fork 64
68 lines (63 loc) · 2.4 KB
/
push-container-on-comment.yml
File metadata and controls
68 lines (63 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Push Container Image On PR Comment
on:
issue_comment:
types: [created]
permissions:
pull-requests: write
contents: write
issues: write
jobs:
push-container-on-comment:
if: contains(github.event.comment.body, '/build-push-pr-image')
runs-on: ubuntu-latest
steps:
- name: Checkout pull request
uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.issue.number }}/head
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Check if the user is authorized
env:
GITHUB_TOKEN: ${{ secrets.RHODS_CI_BOT_PAT }}
GITHUB_PR_NUMBER: ${{ github.event.issue.number }}
GITHUB_EVENT_ACTION: ${{ github.event.action }}
GITHUB_EVENT_REVIEW_STATE: ${{ github.event.review.state }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
COMMENT_BODY: ${{ github.event.comment.body }}
REVIEW_COMMENT_BODY: ${{ github.event.review.body }}
GITHUB_USER_LOGIN: ${{ github.event.sender.login }}
ACTION: "push-container-on-comment"
run: uv run python .github/workflows/scripts/pr_workflow.py
- name: Set env TAG for image
run: |
echo "TAG=pr-${{ github.event.issue.number }}" >> "$GITHUB_ENV"
- name: Build Image to push
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: opendatahub-tests
tags: ${{ env.TAG }}
containerfiles: |
./Dockerfile
- name: Push To Image Registry
id: push-to-registry
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: quay.io/opendatahub
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Add comment to PR
if: always()
env:
URL: ${{ github.event.issue.comments_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl \
-X POST \
$URL \
-H "Content-Type: application/json" \
-H "Authorization: token $GITHUB_TOKEN" \
--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 }}." }'