gitea action to deploy with rsync w ssh key
Some checks failed
Deploy website to VPS / build-and-deploy (push) Failing after 2s
Some checks failed
Deploy website to VPS / build-and-deploy (push) Failing after 2s
This commit is contained in:
81
.gitea/workflows/depoly.yaml
Normal file
81
.gitea/workflows/depoly.yaml
Normal file
@@ -0,0 +1,81 @@
|
||||
name: Deploy website to VPS
|
||||
|
||||
env:
|
||||
NODE_VERSION: '20'
|
||||
HUGO_VERSION: '0.121.0' # Fallback version
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['main']
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest # This maps to your node:20-alpine runner
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install System Dependencies
|
||||
run: |
|
||||
apk add --no-cache rsync openssh-client bash git
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- name: Setup pnpm
|
||||
if: hashFiles('package.json') != ''
|
||||
uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Get Hugo Version
|
||||
run: |
|
||||
if [ -f "hugoblox.yaml" ]; then
|
||||
VERSION=$(grep "hugo_version" hugoblox.yaml | awk '{print $2}' | tr -d "'\"")
|
||||
echo "HUGO_VERSION=$VERSION" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
if [ -f "package.json" ]; then
|
||||
pnpm install --no-frozen-lockfile || npm install
|
||||
fi
|
||||
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v3
|
||||
with:
|
||||
hugo-version: ${{ env.HUGO_VERSION }}
|
||||
extended: true
|
||||
|
||||
- name: Build with Hugo
|
||||
run: |
|
||||
# Use your actual domain here
|
||||
hugo --minify --baseURL "https://ejs.cam/"
|
||||
|
||||
- name: Generate Pagefind search index
|
||||
run: |
|
||||
if [ -f "package.json" ] && grep -q "pagefind" package.json; then
|
||||
pnpm dlx pagefind --source "public" || npx pagefind --source "public"
|
||||
fi
|
||||
|
||||
- name: Deploy via Rsync
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
run: |
|
||||
# Setup SSH
|
||||
mkdir -p ~/.ssh
|
||||
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
|
||||
# Scan host key to prevent MITM prompts
|
||||
ssh-keyscan -p ${{ secrets.REMOTE_PORT }} ${{ secrets.REMOTE_HOST }} >> ~/.ssh/known_hosts
|
||||
|
||||
# Sync files
|
||||
# --delete ensures old files are removed from /var/www
|
||||
rsync -avz --delete \
|
||||
-e "ssh -p ${{ secrets.REMOTE_PORT }}" \
|
||||
./public/ \
|
||||
${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }}:/var/www/
|
||||
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -1,2 +0,0 @@
|
||||
github: gcushen
|
||||
custom: https://hugoblox.com/sponsor/
|
||||
BIN
.github/preview.webp
vendored
BIN
.github/preview.webp
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 48 KiB |
124
.github/workflows/deploy.yml
vendored
124
.github/workflows/deploy.yml
vendored
@@ -1,124 +0,0 @@
|
||||
name: Deploy website to GitHub Pages
|
||||
|
||||
env:
|
||||
NODE_VERSION: '20'
|
||||
|
||||
on:
|
||||
# Trigger the workflow every time you push to the `main` branch
|
||||
push:
|
||||
branches: ['main']
|
||||
# Allows you to run this workflow manually from the Actions tab on GitHub
|
||||
workflow_dispatch:
|
||||
|
||||
# Provide permission to clone the repo and deploy it to GitHub Pages
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: 'pages'
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
# Build website
|
||||
build:
|
||||
if: github.repository_owner != 'HugoBlox'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
# Fetch history for Hugo's .GitInfo and .Lastmod
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- name: Setup pnpm
|
||||
if: hashFiles('package.json') != ''
|
||||
uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Get Hugo Version
|
||||
id: hugo-version
|
||||
run: |
|
||||
VERSION=$(grep "hugo_version" hugoblox.yaml | awk '{print $2}' | tr -d "'\"")
|
||||
echo "HUGO_VERSION=$VERSION" >> $GITHUB_ENV
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
# Install Tailwind CLI if package.json exists
|
||||
if [ -f "package.json" ]; then
|
||||
echo "Installing Tailwind dependencies..."
|
||||
pnpm install --no-frozen-lockfile || npm install
|
||||
fi
|
||||
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v3
|
||||
with:
|
||||
hugo-version: ${{ env.HUGO_VERSION }}
|
||||
extended: true
|
||||
|
||||
# Cache dependencies (Go modules, node_modules) - stable, rarely changes
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
/tmp/hugo_cache_runner/
|
||||
node_modules/
|
||||
modules/*/node_modules/
|
||||
key: ${{ runner.os }}-hugo-deps-${{ hashFiles('**/go.mod', '**/package-lock.json',
|
||||
'**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-hugo-deps-
|
||||
|
||||
# Cache Hugo resources (processed images, CSS) - invalidates only when assets/config change
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: resources/
|
||||
key: ${{ runner.os }}-hugo-resources-${{ hashFiles('assets/**/*', 'config/**/*',
|
||||
'hugo.yaml', 'package.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-hugo-resources-
|
||||
|
||||
- name: Setup Pages
|
||||
id: pages
|
||||
uses: actions/configure-pages@v5
|
||||
|
||||
- name: Build with Hugo
|
||||
env:
|
||||
HUGO_ENVIRONMENT: production
|
||||
run: |
|
||||
echo "Hugo Cache Dir: $(hugo config | grep cachedir)"
|
||||
hugo --minify --baseURL "${{ steps.pages.outputs.base_url }}/"
|
||||
|
||||
- name: Generate Pagefind search index (if applicable)
|
||||
run: |
|
||||
# Check if site uses Pagefind search
|
||||
if [ -f "package.json" ] && grep -q "pagefind" package.json; then
|
||||
pnpm dlx pagefind --source "public" || npx pagefind --source "public"
|
||||
fi
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v4
|
||||
with:
|
||||
path: ./public
|
||||
|
||||
# Deploy website to GitHub Pages hosting
|
||||
deploy:
|
||||
if: github.repository_owner != 'HugoBlox'
|
||||
needs: build
|
||||
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
|
||||
permissions:
|
||||
pages: write # to deploy to Pages
|
||||
id-token: write # to verify the deployment originates from an appropriate source
|
||||
# Deploy to the github-pages environment
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
122
.github/workflows/import-publications.yml
vendored
122
.github/workflows/import-publications.yml
vendored
@@ -1,122 +0,0 @@
|
||||
# Hugo Blox GitHub Action to convert Bibtex publications to Markdown-based webpages
|
||||
name: Import Publications From Bibtex
|
||||
|
||||
# Require permission to create a PR (least privilege principle)
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
# Run workflow when a `.bib` file is added or updated in the `data/` folder
|
||||
on:
|
||||
push:
|
||||
branches: ['main']
|
||||
paths: ['publications.bib']
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# Prevent concurrent runs of this workflow
|
||||
concurrency:
|
||||
group: import-publications-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
hugoblox:
|
||||
if: github.repository_owner != 'HugoBlox'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
env:
|
||||
ACADEMIC_VERSION: '>=0.10.0'
|
||||
PYTHON_VERSION: '3.12'
|
||||
steps:
|
||||
- name: Checkout the repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
# Only need recent history for publication import
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Set up Python 3.13
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
- name: Setup pip cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-academic-${{ env.ACADEMIC_VERSION }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-academic-
|
||||
${{ runner.os }}-pip-
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install "academic${{ env.ACADEMIC_VERSION }}"
|
||||
- name: Validate publications.bib file
|
||||
if: ${{ hashFiles('publications.bib') != '' }}
|
||||
run: |
|
||||
if [ ! -f "publications.bib" ]; then
|
||||
echo "❌ publications.bib file not found"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ publications.bib file found"
|
||||
|
||||
- name: Run Academic (Bibtex To Markdown Converter)
|
||||
# Check `.bib` file exists for case when action runs on `.bib` deletion
|
||||
# Note GH only provides hashFiles func in `steps.if` context, not `jobs.if` context
|
||||
if: ${{ hashFiles('publications.bib') != '' }}
|
||||
run: |
|
||||
echo "🚀 Starting publication import..."
|
||||
academic import publications.bib content/publication/ --compact --verbose
|
||||
echo "✅ Publication import completed successfully"
|
||||
|
||||
# Verify that files were created
|
||||
if [ -d "content/publication" ] && [ "$(ls -A content/publication/)" ]; then
|
||||
echo "📚 Publications imported: $(ls content/publication/ | wc -l) items"
|
||||
else
|
||||
echo "⚠️ No publications were imported"
|
||||
fi
|
||||
continue-on-error: false
|
||||
- name: Create Pull Request
|
||||
# Set ID for `Check outputs` stage
|
||||
id: cpr
|
||||
uses: peter-evans/create-pull-request@v6
|
||||
with:
|
||||
commit-message: 'feat(publications): import latest publications from bibtex'
|
||||
title: 'Hugo Blox Builder - Import latest publications from Bibtex'
|
||||
body: |
|
||||
🔄 **Automated Publication Import**
|
||||
|
||||
This PR automatically imports the latest publications from `publications.bib` to `content/publication/`.
|
||||
|
||||
**Changes:**
|
||||
- 📚 Updated publication entries
|
||||
- 🏷️ Processed bibliographic data
|
||||
|
||||
---
|
||||
将最新的出版物从`publications.bib`导入到`content/publication/`。
|
||||
|
||||
📖 [View Documentation](https://github.com/GetRD/academic-file-converter)
|
||||
base: main
|
||||
labels: automated-pr, content, publications
|
||||
branch: hugoblox-import-publications
|
||||
delete-branch: true
|
||||
draft: false
|
||||
- name: Check outputs
|
||||
if: ${{ steps.cpr.outputs.pull-request-number }}
|
||||
run: |
|
||||
echo "✅ Successfully created Pull Request!"
|
||||
echo "📝 Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
|
||||
echo "🔗 Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
|
||||
echo "🎯 Operation completed at $(date)"
|
||||
|
||||
- name: Report workflow status
|
||||
if: always()
|
||||
run: |
|
||||
if [ "${{ job.status }}" == "success" ]; then
|
||||
echo "🎉 Workflow completed successfully"
|
||||
else
|
||||
echo "❌ Workflow failed - check logs for details"
|
||||
exit 1
|
||||
fi
|
||||
24
.github/workflows/updater-wip.yml
vendored
24
.github/workflows/updater-wip.yml
vendored
@@ -1,24 +0,0 @@
|
||||
# This workflow is only for the Hugo Blox repository. It is safe to delete from your site.
|
||||
name: Updater (WIP)
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: 0 0 * * 0
|
||||
# Allows you to run this workflow manually from the Actions tab on GitHub.
|
||||
workflow_dispatch:
|
||||
|
||||
# Provide permission to clone the repo and deploy it to GitHub Pages
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
update:
|
||||
if: github.repository_owner == 'HugoBlox'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: HugoBlox/gh-action-updater@v2
|
||||
with:
|
||||
feed-url: https://hugoblox.com/rss.xml
|
||||
readme-section: news
|
||||
branch: main
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
Reference in New Issue
Block a user