Skip to content

Commit 25af130

Browse files
authored
Merge branch 'main' into support_build_command
2 parents 934ab72 + 494adec commit 25af130

File tree

97 files changed

+4537
-1540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+4537
-1540
lines changed

.github/workflows/add-remove-labels.yml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@ on:
44
types: [synchronize]
55

66
pull_request_review:
7+
types: [submitted, edited]
8+
9+
pull_request_review_comment:
10+
types: [created, edited]
711

812
issue_comment:
913
types: [created, edited, deleted]
10-
if: |
11-
contains(github.event.comment.body, '/wip') ||
12-
contains(github.event.comment.body, '/verified') ||
13-
contains(github.event.comment.body, '/lgtm') ||
14-
contains(github.event.comment.body, '/hold')
14+
# I don't believe the conditional is supported here
15+
# if: |
16+
# contains(github.event.comment.body, '/wip') ||
17+
# contains(github.event.comment.body, '/verified') ||
18+
# contains(github.event.comment.body, '/lgtm') ||
19+
# contains(github.event.comment.body, '/hold')
1520

1621

1722
permissions:
@@ -31,19 +36,41 @@ jobs:
3136
comment-id: ${{ github.event.comment.id }}
3237
reactions: '+1'
3338

39+
# This currently fails with either the bot PAT or the standard github token secret
40+
# gh: Insufficient scopes for reacting to this Pull Request Review Comment. (HTTP 403)
41+
# {"message":"Insufficient scopes for reacting to this Pull Request Review Comment.","documentation_url":"https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-pull-request-review-comment","status":"403"}
42+
# It could work if we had a token with the proper permissions.
43+
# See https://github.com/peter-evans/create-or-update-comment/issues/392 for why the action above doesn't work.
44+
# Confirmed as a bug, see: https://github.com/github/docs/issues/36899
45+
# - name: Acknowledge the review with thumbs up reaction
46+
# if: ${{ github.event.review }}
47+
# env:
48+
# GH_TOKEN: ${{ secrets.OPENDATAHUB_TESTS_BOT_PAT }}
49+
# REVIEW_COMMENT_ID: ${{ github.event.review.id }}
50+
# REPO_NAME: ${{ github.event.repository.name }}
51+
# REPO_OWNER: ${{ github.event.repository.owner.login }}
52+
# run: |
53+
# gh api \
54+
# --method POST \
55+
# -H "Accept: application/vnd.github+json" \
56+
# -H "X-GitHub-Api-Version: 2022-11-28" \
57+
# /repos/$REPO_OWNER/$REPO_NAME/pulls/comments/$REVIEW_COMMENT_ID/reactions \
58+
# -f "content=+1"
59+
3460
- uses: actions/checkout@v4
3561

3662
- name: Install uv
3763
uses: astral-sh/setup-uv@v5
3864

3965
- name: Run add remove labels
4066
env:
41-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
GITHUB_TOKEN: ${{ secrets.OPENDATAHUB_TESTS_BOT_PAT }}
4268
GITHUB_PR_NUMBER: "${{ github.event.pull_request.number || github.event.issue.number }}"
4369
GITHUB_EVENT_ACTION: ${{ github.event.action }}
4470
GITHUB_EVENT_REVIEW_STATE: ${{ github.event.review.state }}
4571
GITHUB_EVENT_NAME: ${{ github.event_name }}
4672
COMMENT_BODY: ${{ github.event.comment.body }}
73+
REVIEW_COMMENT_BODY: ${{ github.event.review.body }}
4774
GITHUB_USER_LOGIN: ${{ github.event.sender.login }}
4875
ACTION: "add-remove-labels"
4976
run: uv run python .github/workflows/scripts/pr_workflow.py

.github/workflows/add-welcome-comment.yml renamed to .github/workflows/add-welcome-comment-set-assignee.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Add Welcome Comment
1+
name: Add Welcome Comment And Set PR Assignee
22
on:
33
pull_request_target:
44
types: [opened]
@@ -8,7 +8,7 @@ permissions:
88
contents: write
99

1010
jobs:
11-
add-welcome-comment:
11+
add-welcome-comment-set-assignee:
1212
runs-on: ubuntu-latest
1313

1414
steps:
@@ -23,5 +23,5 @@ jobs:
2323
GITHUB_PR_NUMBER: ${{github.event.pull_request.number}}
2424
GITHUB_EVENT_ACTION: ${{github.event.action}}
2525
GITHUB_EVENT_NAME: ${{github.event_name}}
26-
ACTION: "add-welcome-comment"
26+
ACTION: "add-welcome-comment-set-assignee"
2727
run: uv run python .github/workflows/scripts/pr_workflow.py
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 }}." }'
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Run Label Action on PR Review Event
2+
on:
3+
workflow_run:
4+
workflows: ["Dummy Workflow on review"]
5+
types:
6+
- completed
7+
permissions:
8+
pull-requests: write
9+
contents: write
10+
issues: write
11+
12+
jobs:
13+
run_on_workflow_a_success:
14+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Run this on Dummy workflow success
18+
run: echo "Dummy Workflow on review completes successfully"
19+
download_context_artifact:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: 'Download artifact'
23+
uses: actions/github-script@v7
24+
with:
25+
script: |
26+
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
27+
owner: context.repo.owner,
28+
repo: context.repo.repo,
29+
run_id: context.payload.workflow_run.id,
30+
});
31+
32+
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
33+
return artifact.name == "context.json"
34+
})[0];
35+
36+
let download = await github.rest.actions.downloadArtifact({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
artifact_id: matchArtifact.id,
40+
archive_format: 'zip',
41+
});
42+
43+
let fs = require('fs');
44+
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/context.zip`, Buffer.from(download.data));
45+
46+
- name: 'Unzip artifact'
47+
run: unzip context.zip
48+
- name: 'Return Parsed JSON'
49+
uses: actions/github-script@v7
50+
id: return-parsed-json
51+
with:
52+
script: |
53+
let fs = require('fs');
54+
let data = fs.readFileSync('./context.json');
55+
return JSON.parse(data);
56+
outputs:
57+
pr_num: ${{fromJSON(steps.return-parsed-json.outputs.result).pr_num}}
58+
event_action: ${{fromJSON(steps.return-parsed-json.outputs.result).event_action}}
59+
review_state: ${{fromJSON(steps.return-parsed-json.outputs.result).review_state}}
60+
event_name: ${{fromJSON(steps.return-parsed-json.outputs.result).event_name}}
61+
comment_body: ${{fromJSON(steps.return-parsed-json.outputs.result).comment_body}}
62+
review_comment_body: ${{fromJSON(steps.return-parsed-json.outputs.result).review_comment_body}}
63+
user_login: ${{fromJSON(steps.return-parsed-json.outputs.result).user_login}}
64+
action: ${{fromJSON(steps.return-parsed-json.outputs.result).action}}
65+
log_context_values:
66+
needs:
67+
- download_context_artifact
68+
runs-on: ubuntu-latest
69+
steps:
70+
- name: 'Set all Env Variable'
71+
run: |
72+
echo "GITHUB_PR_NUMBER=${{ needs.download_context_artifact.outputs.pr_num }}" >> "$GITHUB_ENV"
73+
echo "GITHUB_EVENT_ACTION=${{ needs.download_context_artifact.outputs.event_action }}" >> "$GITHUB_ENV"
74+
echo "GITHUB_EVENT_REVIEW_STATE=${{ needs.download_context_artifact.outputs.review_state }}" >> "$GITHUB_ENV"
75+
echo "GITHUB_EVENT_NAME=${{ needs.download_context_artifact.outputs.event_name }}" >> "$GITHUB_ENV"
76+
echo "COMMENT_BODY=${{ needs.download_context_artifact.outputs.comment_body }}" >> "$GITHUB_ENV"
77+
echo "REVIEW_COMMENT_BODY=${{ needs.download_context_artifact.outputs.review_comment_body }}" >> "$GITHUB_ENV"
78+
echo "GITHUB_USER_LOGIN=${{ needs.download_context_artifact.outputs.user_login }}" >> "$GITHUB_ENV"
79+
echo "ACTION=${{ needs.download_context_artifact.outputs.action }}" >> "$GITHUB_ENV"
80+
- uses: actions/checkout@v4
81+
82+
- name: Install uv
83+
uses: astral-sh/setup-uv@v5
84+
- name: 'Run add-remove-labels action'
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.OPENDATAHUB_TESTS_BOT_PAT }}
87+
GITHUB_EVENT_NAME: ${{ needs.download_context_artifact.outputs.event_name }}
88+
run: uv run python .github/workflows/scripts/pr_workflow.py

.github/workflows/scripts/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
SUCCESS_STR: str = "success"
1212
FAILURE_STR: str = "failure"
1313
QUEUED_STR: str = "queued"
14+
APPROVED: str = "approved"
1415

1516
SUPPORTED_LABELS: set[str] = {
1617
f"{LABEL_PREFIX}{WIP_LABEL_STR}",
@@ -25,6 +26,7 @@
2526
* PR size label.
2627
* Run [pre-commit](https://pre-commit.ci/)
2728
* Run [tox](https://tox.wiki/)
29+
* Add PR author as the PR assignee
2830
2931
Available user actions:
3032
* To mark a PR as `WIP`, add `/wip` in a comment. To remove it from the PR comment `/wip cancel` to the PR.

0 commit comments

Comments
 (0)