feat: aliyun esa purge #2982
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 0 1 * *' | |
workflow_dispatch: | |
repository_dispatch: | |
types: [build-hugo] | |
jobs: | |
build-deploy: | |
runs-on: ubuntu-latest | |
env: | |
DOCKER_CACHEDIR: /tmp/.docker-cache | |
HUGO_CACHEDIR: /tmp/.hugo_cache | |
HUGOMODS_CACHEDIR: /tmp/.hugo_mods_cache | |
PNPM_CACHEDIR: /tmp/.pnpm-cache | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Cache Docker images | |
id: cache | |
uses: ScribeMD/docker-cache@0.5.0 | |
with: | |
key: docker-${{ runner.os }}-${{ env.DOCKER_ALIYUN_IMG_DEGEST }} | |
- name: Pull Docker Images | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: docker pull fangbinwei/aliyun-oss-website-action:v1 | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v3 | |
with: | |
hugo-version: 'latest' | |
extended: true | |
- name: Build Hugo | |
run: | | |
hugo --minify --enableGitInfo | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
run_install: false | |
- name: Setup Node LTS | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: 'pnpm' | |
cache-dependency-path: '**/pnpm-lock.yaml' | |
# - name: Install and run Shiki | |
# run: | | |
# export NODE_OPTIONS="--max_old_space_size=7168" | |
# pnpm install | |
# pnpm run shiki --silent || true | |
# # npx rehype-cli public -o --silent || 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: Publish to Cloudflare Pages | |
# uses: cloudflare/wrangler-action@v3 | |
# with: | |
# apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
# accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
# quiet: true | |
# command: pages deploy public --project-name=${{ secrets.CLOUDFLARE_PROJECT_NAME }} --commit-dirty=true | |
- name: Aliyun Actions Docker image degest | |
run: | | |
# Check JQ | |
if ! command -v jq &> /dev/null; then | |
echo "jq is not installed. Installing..." | |
sudo apt-get update | |
sudo apt-get install -y jq | |
else | |
echo "jq is already installed." | |
fi | |
# Degest | |
DOCKER_DEGEST=$(curl -s "https://hub.docker.com/v2/namespaces/fangbinwei/repositories/aliyun-oss-website-action/tags/v1" | jq -r '.images[] | select(.architecture == "amd64") | .digest | sub("sha256:"; "")') | |
echo "DOCKER_ALIYUN_IMG_DEGEST=$DOCKER_DEGEST" >> $GITHUB_ENV | |
- name: Deploy to Aliyun OSS | |
uses: docker://fangbinwei/aliyun-oss-website-action:v1 | |
env: | |
ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }} | |
ACCESS_KEY_SECRET: ${{ secrets.ACCESS_KEY_SECRET }} | |
BUCKET: eallion-com | |
ENDPOINT: oss-cn-shanghai.aliyuncs.com | |
FOLDER: public | |
SKIP_SETTING: true | |
INCREMENTAL: true | |
# - 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: Refresh Aliyun ESA | |
run: | | |
pnpm install | |
pnpm run esa | |
env: | |
ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }} | |
ACCESS_KEY_SECRET: ${{ secrets.ACCESS_KEY_SECRET }} | |
ESA_SITE_ID: ${{ secrets.ESA_SITE_ID }} |