Skip to content

Commit 62a12a8

Browse files
authored
[CI] Add upload pr_number artifacts action to ci-e2e-all.yml (#7448)
## Which problem is this PR solving? - Resolves part of #6278 - Supports #7414 ## Description of the changes - Add upload pr_number artifacts action - The ci-comment.yml workflow can now detect pr number by downloading the artifact ## How was this change tested? - from my repostory pull request: pipiland2612#2 - log from the action https://github.com/pipiland2612/jaeger/actions/runs/16997159461/job/48190513998: ``` Successfully extracted metrics_snapshot_elasticsearch_8.x_v2 Processing artifact: diff_metrics_snapshot_elasticsearch_8.x_v2 (ID: 3776313824) Extracting to /home/runner/work/jaeger/jaeger/.metrics/diff_metrics_snapshot_elasticsearch_8.x_v2 Successfully extracted diff_metrics_snapshot_elasticsearch_8.x_v2 Starting PR number detection... Workflow run details: - Head branch: error_branch - Head repository: pipiland2612/jaeger - Commit SHA: 49af2ee Attempt 1: Searching PRs for branch pipiland2612/jaeger:error_branch Found PR Number from artifact: 2 Final PR Number: 2 ``` ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [ ] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `npm run lint` and `npm run test` Signed-off-by: pipiland2612 <[email protected]>
1 parent 97f40a9 commit 62a12a8

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

.github/workflows/ci-comment.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,25 @@ jobs:
6060
head: `${context.payload.workflow_run.head_repository.full_name}:${context.payload.workflow_run.head_branch}`,
6161
});
6262
63-
if (pullRequest.data.length > 0) {
64-
prNumber = pullRequest.data[0].number;
63+
const prArtifactPath = path.join(process.env.GITHUB_WORKSPACE, '.metrics', 'pr_number', 'pr_number.txt');
64+
if (fs.existsSync(prArtifactPath)) {
65+
prNumber = fs.readFileSync(prArtifactPath, 'utf8').trim();
66+
console.log(`Found PR Number from artifact: ${prNumber}`);
6567
} else {
66-
// Fallback to commit SHA if needed
67-
const commitSha = context.payload.workflow_run.head_sha;
68-
const prsForCommit = await github.rest.repos.listPullRequestsAssociatedWithCommit({
69-
owner,
70-
repo,
71-
commit_sha: commitSha,
72-
});
73-
if (prsForCommit.data.length > 0) {
74-
prNumber = prsForCommit.data[0].number;
68+
if (pullRequest.data.length > 0) {
69+
prNumber = pullRequest.data[0].number;
70+
} else {
71+
// Fallback to commit SHA if needed
72+
const commitSha = context.payload.workflow_run.head_sha;
73+
const prsForCommit = await github.rest.repos.listPullRequestsAssociatedWithCommit({
74+
owner,
75+
repo,
76+
commit_sha: commitSha,
77+
});
78+
if (prsForCommit.data.length > 0) {
79+
prNumber = prsForCommit.data[0].number;
80+
console.log(`Found PR via commit SHA: #${prNumber}`);
81+
}
7582
}
7683
}
7784

.github/workflows/ci-e2e-all.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,18 @@ jobs:
3838
uses: ./.github/workflows/ci-e2e-opensearch.yml
3939

4040
query:
41-
uses: ./.github/workflows/ci-e2e-query.yml
41+
uses: ./.github/workflows/ci-e2e-query.yml
42+
43+
upload_pr_number:
44+
name: Save and Upload PR Number as Artifact
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: Save PR number as artifact
48+
if: github.event_name == 'pull_request'
49+
run: echo "${{ github.event.number }}" > pr_number.txt
50+
- name: Upload PR number artifact
51+
if: github.event_name == 'pull_request'
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: pr_number
55+
path: pr_number.txt

0 commit comments

Comments
 (0)