@@ -103,12 +103,45 @@ 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+ run : |
118+ npx zx << 'EOF'
119+ import project from './.vercel/project.json' with {type:"json"};
120+
121+ const [pr, url] = await Promise.all([$`gh pr view ${{ github.event.number }} --json body`, $`cat ./url.txt`]);
122+ const body = JSON.parse(pr.stdout).body;
123+ const lines = body.split('\n');
124+
125+ let linkIndex;
126+
127+ const linkText = `- [${project.projectName}](./url)`;
128+
129+ for (const lineIndex in lines) {
130+ const line = lines[lineIndex];
131+
132+ if (line.startsWith(`- [${project.projectName}]`)) {
133+ lines[lineIndex] = linkText;
134+ linkIndex = +lineIndex;
135+ continue;
136+ }
137+ }
138+
139+ if (typeof linkIndex !== 'number') {
140+ lines.push('\n', linkText);
141+ }
142+
143+ $.sync`echo ${lines.join('\n').trim()} > ./body.txt`
144+
145+ $.sync`gh issue edit ${{ github.event.number }} --body-file ./body.txt`;
146+ EOF
147+
0 commit comments