-
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (90 loc) · 2.96 KB
/
hosting-pr-actions.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
86
87
88
89
90
91
92
93
94
95
name: hosting-pr-actions
on:
pull_request:
branches-ignore:
- "master"
paths:
- "Hosting/**"
defaults:
run:
working-directory: Hosting
jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/cache/restore@v4
id: cache-restore
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('Hosting/package-lock.json') }}
- if: steps.cache-restore.outputs.cache-hit != 'true'
run: npm ci
- name: Cache node_modules
if: steps.cache-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
id: cache
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('Hosting/package-lock.json') }}
prettier:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('Hosting/package-lock.json') }}
- uses: technote-space/get-diff-action@v6 #差分を取得
with:
PATTERNS: "**/*.{ts,tsx,js,jsx}"
RELATIVE: "Hosting"
- name: Run Prettier
run: |
npm ci
npx prettier --write ${{ env.GIT_DIFF_FILTERED }} # 環境変数GIT_DIFF_FILTEREDに差分のあるファイルが列挙されている
if: env.GIT_DIFF
- uses: stefanzweifel/git-auto-commit-action@v4 # フォーマットしたファイルをコミット
with:
commit_message: Apply Prettier Change
eslint:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('Hosting/package-lock.json') }}
- name: Run ESLint
uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
workdir: Hosting
eslint_flags: "src/**/*.{js,jsx,ts,tsx}"
fail_on_error: true # 指摘が発生したらjobを失敗扱いにする
deploy:
if: "${{ github.event.pull_request.head.repo.full_name == github.repository }}"
needs: [setup, prettier, eslint]
environment: production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('Hosting/package-lock.json') }}
- run: npm ci && npm run build
env:
MAPS_JS_API: ${{ secrets.MAPS_JS_API }}
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_GALLERY_FOUND }}"
entryPoint: ./Hosting
projectId: gallery-found