@@ -103,12 +103,46 @@ jobs:
103103 run : >-
104104 npx vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} &&
105105 npx vercel build &&
106- npx vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
106+ npx vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > url.txt
107107
108108 - name : Vercel Pull/Build/Deploy (Production)
109109 working-directory : examples/vite
110110 if : ${{ github.ref_name == 'master' }}
111111 run : >-
112112 npx vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} &&
113113 npx vercel build --prod &&
114- npx vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
114+ npx vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > url.txt
115+
116+ - name : Add links
117+ working-directory : examples/vite
118+ run : |
119+ npx zx << 'EOF'
120+ import project from './.vercel/project.json' with {type:"json"};
121+
122+ const [pr, url] = await Promise.all([$`gh pr view ${{ github.event.number }} --json body`, $`cat ./url.txt`]);
123+ const body = JSON.parse(pr.stdout).body;
124+ const lines = body.split('\n');
125+
126+ let linkIndex;
127+
128+ const linkText = `- [${project.projectName}](./url)`;
129+
130+ for (const lineIndex in lines) {
131+ const line = lines[lineIndex];
132+
133+ if (line.startsWith(`- [${project.projectName}]`)) {
134+ lines[lineIndex] = linkText;
135+ linkIndex = +lineIndex;
136+ continue;
137+ }
138+ }
139+
140+ if (typeof linkIndex !== 'number') {
141+ lines.push('\n', linkText);
142+ }
143+
144+ $.sync`echo ${lines.join('\n').trim()} > ./body.txt`
145+
146+ $.sync`gh issue edit ${{ github.event.number }} --body-file ./body.txt`;
147+ EOF
148+
0 commit comments