Skip to content

Commit

Permalink
Fix comment publishing action
Browse files Browse the repository at this point in the history
  • Loading branch information
modos189 committed May 4, 2024
1 parent 5555c25 commit 34273bf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
FILE_NAME="${FILE_NAME}-$(echo ${{ github.event.pull_request.head.sha }} | cut -c 1-6)"
echo "PR" > ./build/.metadata/build_type
echo ${{ github.event.pull_request.head.sha }} > ./build/.metadata/commit
echo ${{ github.event.number }} > ./build/.metadata/pr_number
fi
mv $ORIGINAL_FILE_NAME "./build/$FILE_NAME".zip
Expand Down
29 changes: 22 additions & 7 deletions .github/workflows/comment-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,41 @@ jobs:
});
artifacts.data.artifacts.forEach((artifact, index) => {
const nameVar = `artifact${index + 1}`;
const displayNameVar = `displayArtifact${index + 1}`;
const urlVar = `url${index + 1}`;
let displayName = artifact.name.endsWith('-artifacts') ? `**${artifact.name}**` : artifact.name;
core.exportVariable(nameVar, displayName);
core.exportVariable(nameVar, artifact.name);
core.exportVariable(displayNameVar, displayName);
core.exportVariable(urlVar, `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}/artifacts/${artifact.id}`);
});
- name: Download and extract first artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.artifact1 }}

- name: Extract PR number from artifact
run: |
if [ -f "build/.metadata/pr_number" ]; then
PR_NUMBER=$(cat build/.metadata/pr_number)
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
fi
- name: Comment with artifact links for PR
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ env.PR_NUMBER != '' }}
with:
header: pr_artifacts
number: ${{ github.event.workflow_run.pull_requests[0].number }}
number: ${{ env.PR_NUMBER }}
message: |
Build completed successfully. Below are the download links for the build artifacts:
| Artifact Name | Download Link |
| ------------- | ------------- |
| ${{ env.artifact1 }} | [Download](${{ env.url1 }}) |
| ${{ env.artifact2 }} | [Download](${{ env.url2 }}) |
| ${{ env.artifact3 }} | [Download](${{ env.url3 }}) |
| ${{ env.artifact4 }} | [Download](${{ env.url4 }}) |
| ${{ env.artifact5 }} | [Download](${{ env.url5 }}) |
| ${{ env.displayArtifact1 }} | [Download](${{ env.url1 }}) |
| ${{ env.displayArtifact2 }} | [Download](${{ env.url2 }}) |
| ${{ env.displayArtifact3 }} | [Download](${{ env.url3 }}) |
| ${{ env.displayArtifact4 }} | [Download](${{ env.url4 }}) |
| ${{ env.displayArtifact5 }} | [Download](${{ env.url5 }}) |
Artifacts will only be retained for 90 days.

0 comments on commit 34273bf

Please sign in to comment.