Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6547606

Browse files
committedFeb 12, 2024·
chore(gh-action): create comment action
1 parent 5113561 commit 6547606

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
 
+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Comment on the pull request the artifact url
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Publish artifacts"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
upload:
11+
runs-on: ubuntu-latest
12+
if: >
13+
github.event.workflow_run.event == 'pull_request' &&
14+
github.event.workflow_run.conclusion == 'success'
15+
steps:
16+
# - name: 'Download artifact'
17+
# uses: actions/github-script@v6
18+
# with:
19+
# script: |
20+
# let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
21+
# owner: context.repo.owner,
22+
# repo: context.repo.repo,
23+
# run_id: context.payload.workflow_run.id,
24+
# });
25+
# let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
26+
# return artifact.name == "pr_number"
27+
# })[0];
28+
# let download = await github.rest.actions.downloadArtifact({
29+
# owner: context.repo.owner,
30+
# repo: context.repo.repo,
31+
# artifact_id: matchArtifact.id,
32+
# archive_format: 'zip',
33+
# });
34+
# let fs = require('fs');
35+
# fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data));
36+
# - name: 'Download artifact'
37+
# uses: actions/github-script@v3.1.0
38+
# with:
39+
# script: |
40+
# var artifacts = await github.actions.listWorkflowRunArtifacts({
41+
# owner: context.repo.owner,
42+
# repo: context.repo.repo,
43+
# run_id: ${{github.event.workflow_run.id }},
44+
# });
45+
# var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
46+
# print(artifact.name);
47+
# return artifact.name == "limeAppBuild"
48+
# })[0];
49+
# print(matchArtifact);
50+
# var download = await github.actions.downloadArtifact({
51+
# owner: context.repo.owner,
52+
# repo: context.repo.repo,
53+
# artifact_id: matchArtifact.id,
54+
# archive_format: 'zip',
55+
# });
56+
# var fs = require('fs');
57+
# fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
58+
# - run: unzip pr.zip
59+
# - name: 'Comment on PR'
60+
# uses: actions/github-script@v3
61+
# with:
62+
# github-token: ${{ secrets.GITHUB_TOKEN }}
63+
# script: |
64+
# var fs = require('fs');
65+
# var issue_number = Number(fs.readFileSync('./NR'));
66+
# await github.issues.createComment({
67+
# owner: context.repo.owner,
68+
# repo: context.repo.repo,
69+
# issue_number: issue_number,
70+
# body: 'Everything is OK. Thank you for the PR!'
71+
# });
72+
73+
- name: 'Comment on PR'
74+
uses: actions/github-script@v3
75+
with:
76+
github-token: ${{ secrets.GITHUB_TOKEN }}
77+
script: |
78+
console.log(${{github.event.workflow_run.artifacts_url}});
79+
console.log(${{github.event.workflow_run}});
80+
81+
- uses: actions/download-artifact@v4
82+
with:
83+
name: limeApp
84+
github-token: ${{ secrets.GITHUB_TOKEN }}
85+
run-id: ${{github.event.workflow_run.id }}

0 commit comments

Comments
 (0)
Please sign in to comment.