Skip to content

Commit ee4667d

Browse files
Initial commit
1 parent ead6cb5 commit ee4667d

1 file changed

Lines changed: 43 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: CI
22

3-
on: [push]
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
49

510
env:
611
BUILD_CACHE_KEY: ${{ github.sha }}-dist
@@ -103,12 +108,47 @@ jobs:
103108
run: >-
104109
npx vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} &&
105110
npx vercel build &&
106-
npx vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
111+
npx vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > url.txt
107112
108113
- name: Vercel Pull/Build/Deploy (Production)
109114
working-directory: examples/vite
110115
if: ${{ github.ref_name == 'master' }}
111116
run: >-
112117
npx vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} &&
113118
npx vercel build --prod &&
114-
npx vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
119+
npx vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > url.txt
120+
121+
- name: Add links
122+
working-directory: examples/vite
123+
env:
124+
GH_TOKEN: ${{ github.token }}
125+
run: |
126+
npx zx << 'EOF'
127+
import project from './.vercel/project.json' with {type:"json"};
128+
129+
const [pr, url] = await Promise.all([$`gh pr view ${{ github.event.number }} --json body`, $`cat ./url.txt`]);
130+
const body = JSON.parse(pr.stdout).body;
131+
const lines = body.split('\n');
132+
133+
let linkIndex;
134+
135+
const linkText = `- [${project.projectName}](${url.stdout})`;
136+
137+
for (const lineIndex in lines) {
138+
const line = lines[lineIndex];
139+
140+
if (line.startsWith(`- [${project.projectName}]`)) {
141+
lines[lineIndex] = linkText;
142+
linkIndex = +lineIndex;
143+
continue;
144+
}
145+
}
146+
147+
if (typeof linkIndex !== 'number') {
148+
lines.push('\n', linkText);
149+
}
150+
151+
$.sync`echo ${lines.join('\n').trim()} > ./body.txt`
152+
153+
$.sync`gh issue edit ${{ github.event.number }} --body-file ./body.txt`;
154+
EOF

0 commit comments

Comments
 (0)