-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (71 loc) · 2.46 KB
/
ci.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
name: CI
on:
push:
branches: ["main"]
pull_request_target:
branches: ["main"]
workflow_dispatch:
jobs:
ci:
runs-on: macos-latest # pagefind not working on x64 architecture
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
lfs: true
- name: Check Project Node version
id: check-node-version
run: echo "node_version=$(jq -r ".volta.node" package.json)" >> $GITHUB_OUTPUT
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ steps.check-node-version.outputs.node_version }}
cache: npm
- name: Run npm ci
run: npm ci
- name: Get GitHub App Token
if: github.event_name == 'pull_request_target'
uses: actions/create-github-app-token@v1
id: github-app
with:
app-id: ${{ secrets.EDITOR_BOT_APP_ID }}
private-key: ${{ secrets.EDITOR_BOT_APP_PRIVATE_KEY }}
- name: Textlint to PR
if: github.event_name == 'pull_request_target'
uses: tsuyoshicho/action-textlint@v3
with:
github_token: ${{ steps.github-app.outputs.token }}
reporter: github-pr-review
textlint_flags: "src/content/**"
fail_on_error: true
- name: Set Build parameter
id: build-parameter
env:
HEAD_REF: ${{ github.head_ref }}
run: |
if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then
echo "root_url=https://${HEAD_REF}--legwiki.netlify.app" >> $GITHUB_OUTPUT
echo "is_production=false" >> $GITHUB_OUTPUT
else
echo "root_url=https://legwiki.lkj.io" >> $GITHUB_OUTPUT
echo "is_production=true" >> $GITHUB_OUTPUT
fi
- name: Run astro check
run: npm run check
- name: Run astro build
run: npm run build
env:
RAKUTEN_APPLICATION_ID: ${{ secrets.RAKUTEN_APPLICATION_ID }}
RAKUTEN_AFFILIATE_ID: ${{ secrets.RAKUTEN_AFFILIATE_ID }}
ROOT_URL: ${{ steps.build-parameter.outputs.root_url }}
- name: Deploy to Netlify
uses: nwtgck/[email protected]
with:
alias: ${{ github.head_ref }}
publish-dir: './dist'
production-deploy: ${{ steps.build-parameter.outputs.is_production }}
github-token: ${{ github.token }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}