Skip to content

Commit fd35839

Browse files
committed
feat: Simplify PR preview registration by removing unnecessary environment variables and updating preview URL handling
1 parent 64eb877 commit fd35839

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

.github/workflows/pr-preview-cleanup.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ jobs:
3636
--header "Authorization: Bearer $PREVIEW_REGISTRATION_TOKEN"
3737
3838
- name: Remove preview block from PR description
39-
if: ${{ steps.config.outputs.configured == 'true' }}
4039
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
4140
with:
4241
script: |

.github/workflows/pr-preview-register.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ jobs:
3030
if: ${{ steps.config.outputs.configured == 'true' }}
3131
id: metadata
3232
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
33-
env:
34-
PREVIEW_BASE_URL: ${{ vars.PR_PREVIEW_BASE_URL }}
3533
with:
3634
script: |
3735
const run = context.payload.workflow_run;
@@ -60,16 +58,13 @@ jobs:
6058
return;
6159
}
6260
63-
const previewUrl = new URL(`/prs/${pullRequest.number}`, process.env.PREVIEW_BASE_URL).toString();
64-
6561
core.setOutput('should_register', 'true');
6662
core.setOutput('pr_number', String(pullRequest.number));
6763
core.setOutput('artifact_name', artifactName);
6864
core.setOutput('head_sha', run.head_sha);
6965
core.setOutput('run_id', String(run.id));
7066
core.setOutput('run_attempt', String(run.run_attempt));
7167
core.setOutput('completed_at', run.updated_at ?? run.created_at);
72-
core.setOutput('preview_url', previewUrl);
7368
7469
- name: Register preview build
7570
if: ${{ steps.config.outputs.configured == 'true' && steps.metadata.outputs.should_register == 'true' }}
@@ -116,15 +111,15 @@ jobs:
116111
if: ${{ steps.config.outputs.configured == 'true' && steps.metadata.outputs.should_register == 'true' }}
117112
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
118113
env:
119-
PREVIEW_URL: ${{ steps.metadata.outputs.preview_url }}
114+
PREVIEW_BASE_URL: ${{ vars.PR_PREVIEW_BASE_URL }}
120115
PR_NUMBER: ${{ steps.metadata.outputs.pr_number }}
121-
RUN_ID: ${{ steps.metadata.outputs.run_id }}
122-
RUN_ATTEMPT: ${{ steps.metadata.outputs.run_attempt }}
123116
with:
124117
script: |
125118
const markerStart = '<!-- pr-preview:start -->';
126119
const markerEnd = '<!-- pr-preview:end -->';
127120
const prNumber = Number(process.env.PR_NUMBER);
121+
const previewUrl = new URL(`/prs/${prNumber}/`, process.env.PREVIEW_BASE_URL).toString();
122+
const badgeUrl = `https://img.shields.io/badge/aspire.dev-${encodeURIComponent(`PR #${prNumber}`)}-512BD4?style=for-the-badge&labelColor=512BD4&color=555555`;
128123
129124
const pullRequest = await github.rest.pulls.get({
130125
owner: context.repo.owner,
@@ -135,12 +130,9 @@ jobs:
135130
const existingBody = pullRequest.data.body ?? '';
136131
const previewBlock = [
137132
markerStart,
138-
'## PR Preview',
139-
'',
140-
`Preview: [Open the latest PR preview](${process.env.PREVIEW_URL})`,
133+
'## 🌐 Preview',
141134
'',
142-
`- CI run: [#${process.env.RUN_ID}](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${process.env.RUN_ID})`,
143-
`- Run attempt: ${process.env.RUN_ATTEMPT}`,
135+
`[![](${badgeUrl})](${previewUrl})`,
144136
markerEnd,
145137
].join('\n');
146138

0 commit comments

Comments
 (0)