ci: deploy to cloudflare pages #2883
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 Hugo and Deploy | |
on: | |
push: | |
branches: | |
- main | |
# schedule: | |
# - cron: 0 16 * * * | |
workflow_dispatch: | |
repository_dispatch: | |
types: [build-hugo] | |
jobs: | |
build-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v3 | |
with: | |
hugo-version: 'latest' | |
extended: true | |
- name: Build Hugo | |
run: | | |
hugo --cleanDestinationDir --forceSyncStatic --gc --ignoreCache --minify --enableGitInfo --templateMetrics --templateMetricsHints | |
- name: Setup Node LTS | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
# cache: yarn | |
- name: Install and run Shiki | |
run: | | |
export NODE_OPTIONS="--max_old_space_size=7168" | |
npm install | |
npm run shiki || true | |
# - name: Deploy to GitHub Pages | |
# uses: peaceiris/actions-gh-pages@v4 | |
# with: | |
# personal_token: ${{ secrets.personal_token }} | |
# external_repository: eallion/blog | |
# publish_branch: main | |
# publish_dir: ./public | |
# # destination_dir: public | |
# allow_empty_commit: true | |
# # commit_message: ${{ GitHub.event.head_commit.message }} | |
# full_commit_message: ${{ github.event.head_commit.message }} | |
# #cname: eallion.com | |
# force_orphan: true | |
# user_name: 'github-actions[bot]' | |
# user_email: 'github-actions[bot]@users.noreply.github.com' | |
# - name: Onionsite Pull Webhook | |
# uses: eallion/fast-webhook@v1 | |
# with: | |
# url: ${{ secrets.ONION_WEBHOOK_URL }} | |
# json: '{"onion": "pull"}' | |
# - name: Algolia uploader | |
# uses: wangchucheng/algolia-uploader@master | |
# with: | |
# app_id: ${{ secrets.ALGOLIA_APPID }} | |
# admin_key: ${{ secrets.ALGOLIA_ADMIN_KEY }} | |
# index_name: eallion | |
# index_file_path: public/index.json | |
# - name: Algolia uploader English | |
# uses: wangchucheng/algolia-uploader@master | |
# with: | |
# app_id: ${{ secrets.ALGOLIA_APPID }} | |
# admin_key: ${{ secrets.ALGOLIA_ADMIN_KEY }} | |
# index_name: "eallion_blog_en" | |
# index_file_path: public/en/index.json | |
- name: Publish to Cloudflare Pages | |
uses: cloudflare/pages-action@v1 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} | |
directory: public | |
# Optional: Enable this if you want to have GitHub Deployments triggered | |
# gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
# Optional: Switch what branch you are publishing to. | |
# By default this will be the branch which triggered this workflow | |
# branch: main | |
# Optional: Change the working directory | |
# workingDirectory: my-site | |
# Optional: Change the Wrangler version, allows you to point to a specific version or a tag such as `beta` | |
wranglerVersion: '3' | |
- name: Deploy to Aliyun OSS | |
uses: fangbinwei/aliyun-oss-website-action@v1 | |
with: | |
accessKeyId: ${{ secrets.ACCESS_KEY_ID }} | |
accessKeySecret: ${{ secrets.ACCESS_KEY_SECRET }} | |
bucket: eallion-com | |
endpoint: oss-cn-shanghai.aliyuncs.com | |
folder: public | |
skipSetting: true | |
# exclude: | | |
# tmp.txt | |
- name: Refresh volcengine CDN | |
run: | | |
curl -s "https://api.github.com/repos/volcengine/volcengine-cli/releases/latest" | grep "browser_download_url.*linux_amd64.zip" | cut -d : -f 2,3 | tr -d \" | wget -O ve.zip -qi - | |
unzip -q ve.zip > /dev/null 2>&1 | |
chmod a+x ./ve | |
./ve configure set --profile volcengine-hugo-github-actions --region cn-beijing --endpoint cdn.volcengineapi.com --access-key ${{ secrets.VOLC_ACCESS_KEY }} --secret-key ${{ secrets.VOLC_SECRET_KEY }} | |
./ve cdn SubmitRefreshTask --body '{"Type":"dir","Urls":"https://www.eallion.com/"}' > /dev/null 2>&1 || true | |
# - name: Upload to Tencent COS CN | |
# uses: zkqiang/[email protected] | |
# with: | |
# args: upload -rsf --delete ./public/ / | |
# secret_id: ${{ secrets.SECRET_COS_ID }} | |
# secret_key: ${{ secrets.SECRET_COS_KEY }} | |
# bucket: ${{ secrets.COS_CN_BUCKET }} | |
# region: ap-shanghai | |
# - name: Tencent CDN Purge | |
# uses: keithnull/[email protected] | |
# env: | |
# SECRET_ID: ${{ secrets.SECRET_COS_ID }} | |
# SECRET_KEY: ${{ secrets.SECRET_COS_KEY }} | |
# PATHS: "https://eallion.com/,https://www.eallion.com/" | |
# FLUSH_TYPE: "delete" # optional | |
# - name: Install TencentCloud CLI | |
# run: | | |
# pip install tccli | |
# - name: Configure Tccli Credentials | |
# run: | | |
# tccli configure set secretId ${{ secrets.TENCENTCLOUD_TEO_SECRET_ID }} | |
# tccli configure set secretKey ${{ secrets.TENCENTCLOUD_TEO_SECRET_KEY }} | |
# - name: Create Tencent Cloud TEO Purge Task | |
# run: | | |
# tccli teo CreatePurgeTask --cli-unfold-argument --ZoneId ${{ secrets.TENCENTCLOUD_TEO_ZONEID }} --Type purge_prefix --Method invalidate --Targets 'https://www.eallion.com/' |