77 e2e :
88 runs-on : ubuntu-latest
99 permissions :
10- contents : read
10+ contents : write
1111 pull-requests : write
1212 steps :
1313 - uses : actions/checkout@v4
14+ with :
15+ fetch-depth : 0
1416 - uses : actions/setup-go@v5
1517 with :
1618 go-version : stable
@@ -34,31 +36,53 @@ jobs:
3436 path : e2e-artifacts
3537 if-no-files-found : warn
3638 retention-days : 7
37- - name : Comment with e2e artifacts
38- if : always()
39+ - name : Publish gifs to e2e-artifacts branch
40+ if : always() && github.event.pull_request.head.repo.fork == false
41+ env :
42+ RUN_ID : ${{ github.run_id }}
43+ run : |
44+ set -euo pipefail
45+ if ! ls e2e-artifacts/*.gif >/dev/null 2>&1; then
46+ echo "No gifs to publish"
47+ exit 0
48+ fi
49+ git config user.name "github-actions[bot]"
50+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
51+ if git show-ref --quiet refs/remotes/origin/e2e-artifacts; then
52+ git checkout -B e2e-artifacts origin/e2e-artifacts
53+ else
54+ git checkout --orphan e2e-artifacts
55+ git rm -rf . >/dev/null 2>&1 || true
56+ fi
57+ mkdir -p "e2e/${RUN_ID}"
58+ cp e2e-artifacts/*.gif "e2e/${RUN_ID}/"
59+ git add "e2e/${RUN_ID}"
60+ git commit -m "e2e gifs for run ${RUN_ID}"
61+ git push origin e2e-artifacts
62+ - name : Comment with e2e gifs
63+ if : always() && github.event.pull_request.head.repo.fork == false
3964 uses : actions/github-script@v7
4065 with :
4166 script : |
4267 const marker = "<!-- e2e-gifs -->";
4368 const { owner, repo } = context.repo;
4469 const issue_number = context.payload.pull_request.number;
45- const run_id = context.runId;
46- const artifactsUrl = `https://github.com/${owner}/${repo}/actions/runs/${run_id}#artifacts`;
47- const { data } = await github.rest.actions.listWorkflowRunArtifacts({
48- owner,
49- repo,
50- run_id,
51- per_page: 100,
52- });
53- const lines = data.artifacts.length
54- ? data.artifacts.map((artifact) => `- ${artifact.name}`)
55- : ["- (no artifacts found)"];
70+ const run_id = context.runId.toString();
71+ const fs = require("fs");
72+ const dir = "e2e-artifacts";
73+ let files = [];
74+ if (fs.existsSync(dir)) {
75+ files = fs
76+ .readdirSync(dir)
77+ .filter((file) => file.toLowerCase().endsWith(".gif"));
78+ }
79+ const base = `https://raw.githubusercontent.com/${owner}/${repo}/e2e-artifacts/e2e/${run_id}`;
80+ const lines = files.length
81+ ? files.map((file) => `})`)
82+ : ["(no gifs found)"];
5683 const body = [
5784 marker,
58- "E2E gifs are available as workflow artifacts:",
59- artifactsUrl,
60- "",
61- "Artifacts:",
85+ "E2E gifs:",
6286 ...lines,
6387 ].join("\n");
6488 const { data: comments } = await github.rest.issues.listComments({
0 commit comments