Skip to content

Commit

Permalink
feat: update cd pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
HEIGE-PCloud committed Dec 20, 2024
1 parent 2efa1cd commit 03f96dd
Showing 1 changed file with 13 additions and 41 deletions.
54 changes: 13 additions & 41 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,13 @@ on:
- 'main'

schedule:
- cron: '0 * * * *' # run every hour
- cron: '0 0 * * *' # run everyday at 00:00 UTC https://crontab.guru/every-day-at-midnight
workflow_dispatch:


# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
group: "deploy"
cancel-in-progress: true

# Default to bash
Expand All @@ -27,20 +21,17 @@ defaults:
shell: bash

env:
NODE_VERSION: 16.x
NODE_VERSION: 23.x

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
env:
CLOUDFLARE_PAGES_DEPLOY_HOOK: ${{ secrets.CLOUDFLARE_PAGES_DEPLOY_HOOK }}

steps:
- name: Trigger Cloudflare Pages build
if: startsWith(env.CLOUDFLARE_PAGES_DEPLOY_HOOK, 'https://api.cloudflare.com/client/v4/pages/webhooks/deploy_hooks/') && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
run: curl -X POST ${{ secrets.CLOUDFLARE_PAGES_DEPLOY_HOOK }}


- uses: actions/checkout@v4
with:
submodules: true # Fetch Hugo themes (true OR recursive)
Expand All @@ -51,41 +42,22 @@ jobs:
with:
node-version: ${{ env.NODE_VERSION }}

- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: 'latest'
extended: true

- name: Setup Pages
id: pages
uses: actions/configure-pages@v5

- name: Build with Hugo
env: # Or as an environment variable
- name: Sync content with Notion
env:
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
run: |
npm install
npm start
hugo
# - name: Commit updated content
# uses: stefanzweifel/git-auto-commit-action@v4
# with:
# commit_message: Sync content with Notion
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
- name: Commit updated content
uses: stefanzweifel/git-auto-commit-action@v4
with:
path: ./public
commit_message: Sync content with Notion

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Trigger Cloudflare Pages build
if: startsWith(env.CLOUDFLARE_PAGES_DEPLOY_HOOK, 'https://api.cloudflare.com/client/v4/pages/webhooks/deploy_hooks/') && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
run: curl -X POST ${{ secrets.CLOUDFLARE_PAGES_DEPLOY_HOOK }}

0 comments on commit 03f96dd

Please sign in to comment.