ci: fix flamegraph preview publishing#5773
Open
uiolee wants to merge 3 commits into
Open
Conversation
How to testgit clone -b fix/flamegraph_publish https://github.com/hexojs/hexo.git
cd hexo
npm install
npm test |
Contributor
There was a problem hiding this comment.
Pull request overview
Reworks the flamegraph preview publishing CI because, due to GitHub's tightened security policy, secrets are no longer available to workflows triggered by pull_request. Publishing for PR builds is moved into a new workflow_run-triggered workflow that can safely access the surge.sh credentials, the directory layout is consolidated so a single sha (or PR) maps to a single surge project, and a protected environment is used to gate the secrets.
Changes:
- Restructured artifact/file naming (drop leading dot so
actions/upload-artifactincludes them) and reorganized flamegraphs under a per-node-version subfolder of a single./flamegraph/project. - Added new
profiling-previewjob (inbenchmark.yml) for push/main builds and a newbenchmark-post.ymlworkflow that runs onworkflow_runto publish PR previews and post the sticky PR comment. - Removed the obsolete
comment-flamegraphjob fromcommenter.yml.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
.github/workflows/benchmark.yml |
Moves flamegraphs into ./flamegraph/<node>/, uploads them as artifacts, and adds a new profiling-preview job that publishes to surge for non-PR events; renames temp files without the leading dot. |
.github/workflows/benchmark-post.yml |
New workflow that, after a successful Benchmark run on a PR, downloads the artifacts, publishes to a per-PR surge subdomain, and posts/updates the sticky PR comment under a protected environment. |
.github/workflows/commenter.yml |
Removes the now-redundant workflow_run trigger and comment-flamegraph job, which have been replaced by benchmark-post.yml. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+91
to
+102
| url: https://${{ github.sha }}-hexo.surge.sh/ | ||
| comment_result: "tmp-comment-flamegraph.md" | ||
| steps: | ||
| - uses: actions/download-artifact@v8 | ||
| with: | ||
| pattern: "comment-*" | ||
| merge-multiple: true | ||
|
|
||
| - name: Publish flamegraph to ${{ env.url }} | ||
| uses: dswistowski/surge-sh-action@v1 | ||
| with: | ||
| domain: ${{ env.url }} |
Comment on lines
+39
to
+46
|
|
||
| echo "pr_number=$pr_number" | tee -a "$GITHUB_OUTPUT" | ||
| echo "url=https://$pr_number-pr-hexo.surge.sh/" | tee -a "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Publish flamegraph to ${{ steps.get_info.outputs.url }} | ||
| uses: dswistowski/surge-sh-action@v1 | ||
| with: | ||
| domain: ${{ steps.get_info.outputs.url }} |
| profiling-preview: | ||
| needs: profiling | ||
| if: ${{ github.event_name != 'pull_request' }} | ||
| runs-on: ubuntu-slim |
| if: | ||
| ${{ github.event_name == 'workflow_run' && github.event.workflow_run.event | ||
| == 'pull_request' && github.event.workflow_run.conclusion == 'success' }} | ||
| runs-on: ubuntu-slim |
| steps: | ||
| - uses: actions/download-artifact@v8 | ||
| with: | ||
| pattern: "comment-*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does it do?
since github action security policy strengthen, secrets could not be accessed in workflow 'on.pull_request'.
Previously one
shaoccupy 3 projects. Now oneshaoccupy 1 project (in main branch) or one PR occupy 1 project (in PR)environmentto strengthen secrets' security.Screenshots
Pull request tasks
Add test cases for the changes.