Skip to content

Instantly share code, notes, and snippets.

@PttCodingMan
Created July 15, 2023 05:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PttCodingMan/e303178da7886baa6f2e08f2ae979658 to your computer and use it in GitHub Desktop.
Save PttCodingMan/e303178da7886baa6f2e08f2ae979658 to your computer and use it in GitHub Desktop.
name: deploy-blog
on:
schedule:
- cron: '22 22 * * *'
push:
branches:
- publish
paths:
- 'source/**/*.md'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
name: Deploy blog.
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true # Checkout private submodules(themes or something else).
- name: Set timezone
uses: szenius/set-timezone@v1.2
with:
timezoneLinux: "Asia/Taipei"
- name: Cache node modules
uses: actions/cache@v3
id: cache
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Update rating
id: update_rating
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Output api.json
run: |
echo "${{ secrets.G_API }}" > .scripts/api.json
- name: Update rating
env:
VIEW_ID: ${{ secrets.G_VIEW_ID }}
GOOGLE_APPLICATION_CREDENTIALS: './.scripts/api.json'
run: |
python .scripts/update_rating.py
- name: Update related posts
run: |
cd .scripts
python related_post.py
- name: Deploy
id: deploy
uses: sma11black/hexo-action@v1.0.4
with:
deploy_key: ${{ secrets.DEPLOY_KEY }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment