Skip to content

Commit df5fbba

Browse files
committed
ci: add Cloudflare Pages Deployed
1 parent 77ff639 commit df5fbba

File tree

4 files changed

+383
-6
lines changed

4 files changed

+383
-6
lines changed

.github/get-cloudflare-page-url.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* eslint-disable no-console */
2+
const JSDOM = require('jsdom').JSDOM
3+
4+
const [html] = process.argv.slice(2)
5+
const { document } = new JSDOM(html).window
6+
7+
const linkElement = document.querySelector('a')
8+
console.log(linkElement?.href ? linkElement.href.replace(/[/]$/, '') : '')
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Cloudflare Pages Deployed
2+
3+
on:
4+
check_run:
5+
types: [completed]
6+
7+
jobs:
8+
build:
9+
name: Test
10+
runs-on: ubuntu-latest
11+
# if: github.event.check_run.pull_requests.length != 0
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-node@v3
16+
with:
17+
node-version: '16.x'
18+
cache: 'yarn'
19+
- run: echo ${{ github.event.check_run.pull_requests.length }}
20+
- run: echo ${{ github.event.check_run.pull_requests.length != 0 }}
21+
- run: echo ${{ github.event.check_run.pull_requests.length != '0' }}
22+
- run: echo ${{ github.event.check_run.pull_requests }}
23+
- run: echo ${{ github.event.check_run.pull_requests[0] }}
24+
25+
- name: Set testing state
26+
uses: thollander/actions-comment-pull-request@v1
27+
with:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
pr_number: 47
30+
comment_includes: 'Playwright tests'
31+
message: |
32+
## 'Playwright tests'
33+
testing...
34+
35+
- name: Install dependencies
36+
run: yarn install
37+
38+
- name: Check object
39+
run: |
40+
cat << OBJECT
41+
${{ toJson(github) }}
42+
OBJECT
43+
- name: Get Cloudflare Page URL
44+
run: echo "DEPLOYMENT_URL=$(node ${GITHUB_WORKSPACE}/.github/get-cloudflare-page-url.js "${{ github.event.check_run.output.summary }}")"
45+
continue-on-error: true
46+
- run: echo $DEPLOYMENT_URL

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"vuepress": "^1.2.0"
4040
},
4141
"dependencies": {
42+
"jsdom": "^20.0.0",
4243
"vuepress-theme-sidstraw-blog": "file:./.vuepress/theme",
4344
"yaml": "^1.10.0"
4445
}

0 commit comments

Comments
 (0)