-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (133 loc) · 3.86 KB
/
ci.yaml
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9.4.0
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm
- run: pnpm install
- uses: actions/cache@v3
with:
path: dist/cache
key: ${{ runner.os }}-astro-build-${{ github.event_name == 'pull_request' && github.event.pull_request.id || 'main' }}
restore-keys: ${{ runner.os }}-astro-build-
- run: pnpm run build
- uses: actions/upload-pages-artifact@v3
if: github.ref == 'refs/heads/main'
with:
path: dist/out
retention-days: 90
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9.4.0
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm
- run: pnpm install
- run: pnpm run lint
typecheck:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9.4.0
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm
- run: pnpm install
- run: pnpm run typecheck
validate-blog:
if: startsWith(github.head_ref, 'blog/') && !startsWith(github.head_ref, 'blog/admin/') && github.actor != 'oucc-blog-ci[bot]'
# Lintは環境構築していない人のことを考えてCIで行う
needs: [typecheck, build]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9.4.0
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm
- run: pnpm install
- run: |
git fetch origin main
git diff origin/main..HEAD --name-only | xargs pnpm run validate-blog
update-blogmeta:
needs: [validate-blog]
permissions:
contents: write
runs-on: ubuntu-22.04
steps:
- uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- uses: actions/checkout@v4
# Checkout pull request HEAD commit instead of merge commit
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ steps.generate-token.outputs.token }}
- uses: pnpm/action-setup@v4
with:
version: 9.4.0
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm
- run: pnpm install
- name: Update Blog Meta
run: |
git fetch origin main
git diff origin/main..HEAD --name-status | xargs pnpm run update-blogmeta
- run: pnpm run format
- name: Git Commit
run: |
git add -N .
if ! git diff --exit-code --quiet
then
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "[Bot] Update Blog Meta"
git push
fi
deploy:
if: github.ref == 'refs/heads/main'
needs: [build, lint, typecheck]
permissions:
pages: write
id-token: write
concurrency:
group: 'pages'
cancel-in-progress: false
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-22.04
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4