feat: add forgejo ci
This commit is contained in:
49
.forgejo/workflows/deploy.yml
Normal file
49
.forgejo/workflows/deploy.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
name: Deploy Hugo Site
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- forge-ci
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-22.04:docker://node:20-bullseye
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Hugo - latest version
|
||||
run: |
|
||||
apt-get update -y
|
||||
apt-get install -y wget tar jq # Install necessary components
|
||||
# Use the GitHub API to get information about the latest release, then use jq to find out the tag name
|
||||
latest=$(wget -qO- https://api.github.com/repos/gohugoio/hugo/releases/latest | jq -r '.tag_name')
|
||||
echo "Latest Hugo version: $latest"
|
||||
# Use ${latest#v} to strip the v from v1.0.0
|
||||
# See "Substring Removal" in https://tldp.org/LDP/abs/html/string-manipulation.html
|
||||
wget -O hugo.tar.gz "https://github.com/gohugoio/hugo/releases/download/${latest}/hugo_extended_${latest#v}_Linux-64bit.tar.gz"
|
||||
tar -xzf hugo.tar.gz hugo
|
||||
mv hugo /usr/local/bin/hugo
|
||||
chmod +x /usr/local/bin/hugo
|
||||
hugo version
|
||||
|
||||
- name: Build site
|
||||
run: hugo --minify
|
||||
|
||||
- name: Deploy to server via rsync
|
||||
env:
|
||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
|
||||
run: |
|
||||
apt-get install -y rsync openssh-client
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
||||
rsync -avz --delete public/ "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH"
|
||||
Reference in New Issue
Block a user