-
Notifications
You must be signed in to change notification settings - Fork 1
85 lines (72 loc) · 2.69 KB
/
test-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Test deployment
on:
pull_request:
jobs:
test-deploy:
name: Test deployment
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
cache: npm
- name: Install dependencies
run: npm ci
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Test build website
run: npm run build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com
- name: Get GitHub Pages URL
id: pages-url
run: |
echo "https://GIZMODO-WOODS.github.io/gizmodo-woods.github.io/${{ github.event.pull_request.head.sha }}" > pages-url.txt
cat pages-url.txt
- name: Post Preview Link
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const { owner, repo, number } = context.issue;
const prNumber = number;
const previewUrl = fs.readFileSync('pages-url.txt', 'utf8').trim();
const message = `### PRをマージするまでの手順
1. チェックが通っていること\`All checks have passed\`、コンフリクトがないこと\`No conflicts with base branch\`を確認
2. 仮想環境で変更内容を確認
🔗 [プレビューはこちら](${previewUrl})
3. \`Merge pull request\`を押す
4. 適切な\`Commit message\`と\`Extended description\`を設定して、\`Confirm merge\`を押す`;
const { data: comments } = await github.rest.issues.listComments({
owner,
repo,
issue_number: prNumber
});
const botComments = comments.filter(comment => comment.user.login === 'github-actions[bot]');
for (const comment of botComments) {
await github.rest.issues.deleteComment({
owner,
repo,
comment_id: comment.id
});
}
await github.rest.issues.createComment({
owner,
repo,
issue_number: prNumber,
body: message
});