Build and Deploy #35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy | |
on: | |
repository_dispatch: | |
pull_request: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: 0 3 * * * | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [22.x] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: npm | |
- name: Run builds and deploys with ${{ matrix.node-version }} | |
run: | | |
npm i && npm run lint | |
staging: | |
runs-on: ubuntu-latest | |
needs: [build] | |
if: github.ref != 'refs/heads/main' | |
env: | |
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }} | |
ROTION_INCREMENTAL_CACHE: true | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: npm | |
- name: Restore next cache | |
uses: actions/[email protected] | |
with: | |
path: | | |
.next/cache | |
key: nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} | |
restore-keys: | | |
nextjs-${{ hashFiles('**/package-lock.json') }}- | |
- name: Restore rotion cache | |
uses: actions/[email protected] | |
with: | |
path: | | |
.cache | |
public/images | |
public/files | |
key: rotion | |
restore-keys: rotion | |
- name: Run next build | |
run: | | |
npm i && npm run build | |
- name: Deploy by SCP | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.PASSWORD }} | |
port: ${{ secrets.PORT }} | |
source: "out/*" | |
target: "web/stag.fukuokago.dev" | |
release: | |
runs-on: ubuntu-latest | |
needs: [build] | |
if: github.ref == 'refs/heads/main' | |
env: | |
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }} | |
ROTION_INCREMENTAL_CACHE: true | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: npm | |
- name: Restore next cache | |
uses: actions/[email protected] | |
with: | |
path: | | |
.next/cache | |
key: nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} | |
restore-keys: | | |
nextjs-${{ hashFiles('**/package-lock.json') }}- | |
- name: Restore rotion cache | |
uses: actions/[email protected] | |
with: | |
path: | | |
.cache | |
public/images | |
public/files | |
key: rotion | |
restore-keys: rotion | |
- name: Run next build | |
run: | | |
npm i && npm run build | |
- name: Deploy by SCP | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.PASSWORD }} | |
port: ${{ secrets.PORT }} | |
source: "out/*" | |
target: "web/fukuokago.dev" |