Skip to content

Commit 08c9f81

Browse files
Initial commit
1 parent 3d6bd9f commit 08c9f81

1 file changed

Lines changed: 38 additions & 2 deletions

File tree

.github/workflows/ci.yml

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

0 commit comments

Comments
 (0)