From 82c636cb5fbfdab98a62507245a95829a0539d7e Mon Sep 17 00:00:00 2001 From: Leon Xu Date: Sun, 29 Nov 2026 13:29:58 -0800 Subject: [PATCH] Add Gitea Actions workflow to deploy site via SFTP; drop legacy deploy config --- .gitea/workflows/deploy.yml | 43 +++++++++++++++++++++++++++++++++++++ _config.yml | 12 +++-------- 2 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..36b0e25 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,43 @@ +name: Deploy to website + +on: + push: + branches: [master] + workflow_dispatch: + +jobs: + deploy: + # Adjust this label if your act_runner registers under a different one + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Install hexo-cli and yarn + run: npm install -g hexo-cli yarn + + - name: Install dependencies + run: yarn install --frozen-lockfile + + # hexo-deployer-sftp reads credentials from the hexo config, which + # cannot take env vars directly. Generate an override config from + # Gitea Actions secrets instead; it is never committed to the repo. + - name: Write deploy config from secrets + env: + SFTP_HOST: ${{ secrets.SFTP_HOST }} + SFTP_USER: ${{ secrets.SFTP_USER }} + SFTP_PASS: ${{ secrets.SFTP_PASS }} + run: | + printf 'deploy:\n - type: sftp\n host: %s\n port: 22\n user: %s\n pass: %s\n remotePath: /www/wwwroot/leonxu260.dev\n' \ + "$SFTP_HOST" "$SFTP_USER" "$SFTP_PASS" > _deploy.yml + + - name: Build site + run: hexo generate + + - name: Deploy via SFTP + run: hexo deploy --config _config.yml,_deploy.yml diff --git a/_config.yml b/_config.yml index d628a0c..8342ca0 100644 --- a/_config.yml +++ b/_config.yml @@ -119,15 +119,9 @@ ignore: theme: butterfly # Deployment -## Docs: https://hexo.io/docs/one-command-deployment -deploy: - - type: 'sftp' - host: 'f34-preview.awardspace.net' - user: '4077592' - pass: 'bnP9e5XBOHAL3od0Sf*8' - remotePath: 'leonxu260.ml/' - port: 221 - - type: baidu_url_submitter +## Deploys run in Gitea Actions (.gitea/workflows/deploy.yml). +## SFTP credentials are injected there from Gitea Actions secrets +## (SFTP_HOST / SFTP_USER / SFTP_PASS) and never stored in this repo. # Hexo Butterfly Tag Plugins Plus tag_plugins: