Skip to content

Build and Deploy

Build and Deploy #554

Workflow file for this run

name: Build and Deploy
on:
push:
branches:
- master
schedule:
- cron: "0 21 * * *" # UTC 21:00 (北京时间 05:00)
jobs:
build-and-deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node: ["lts/fermium"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: "master"
persist-credentials: false
fetch-depth: 0
env:
TZ: Asia/Shanghai
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "12.18.3"
- name: Get Config
id: config
uses: actions/github-script@v6
with:
script: |
const config = require('./blog.config.cjs')
core.setOutput('userName', config.userName)
core.setOutput('userEmail', config.userEmail)
core.setOutput('baseUrl', config.baseUrl)
core.setOutput('repository', config.repository)
- name: Install Dependencies
run: npm install
- name: Build Nuxt Pages
run: npm run generate
- name: Deploy to Pages
env:
TZ: Asia/Shanghai
USER_NAME: ${{ steps.config.outputs.userName }}
USER_EMAIL: ${{ steps.config.outputs.userEmail }}
BASE_URL: ${{ steps.config.outputs.baseUrl }}
REPO: ${{ steps.config.outputs.repository }}
run: |
cd dist
git init
git config user.name "$USER_NAME"
git config user.email "$USER_EMAIL"
git add .
git commit -m 'Deploying to gh-pages from Github actions'
git push -f https://ACCESS_TOKEN:${{secrets.ACCESS_TOKEN }}@github.com/$USER_NAME/$REPO.git master:gh-pages
cd -