74 lines
2.5 KiB
YAML
74 lines
2.5 KiB
YAML
name: Build and Deploy Zola Site
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main # Or whichever branch you want to deploy from
|
|
|
|
jobs:
|
|
#----------------------------------------------------
|
|
# JOB 1: Build the static site with Zola
|
|
#----------------------------------------------------
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# Step 1: Check out the main website repository's code
|
|
- name: Checkout Website Source
|
|
uses: actions/checkout@v4
|
|
with:
|
|
path: main-site
|
|
|
|
# Step 2: Check out the theme repository into the correct folder
|
|
# Replace 'YourUsername/YourThemeRepo' with your actual Gitea theme repository
|
|
- name: Checkout Theme
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: finmoon/moon-anemone
|
|
path: main-site/themes/anemone
|
|
token: ${{ secrets.ANEMONE_TOKEN }}
|
|
|
|
# Step 3: Install the Zola static site generator
|
|
- name: Install Zola
|
|
uses: taiki-e/install-action@v2
|
|
with:
|
|
tool: zola
|
|
|
|
# Step 4: Run the build command
|
|
# Zola will generate the site in the 'main-site/public' directory
|
|
- name: Build Site
|
|
run: |
|
|
cd main-site
|
|
zola build
|
|
|
|
# Step 5: Upload the 'public' directory as an artifact
|
|
# This makes the build output available to other jobs (like our deploy job)
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: zola-public
|
|
path: main-site/public/
|
|
|
|
#----------------------------------------------------
|
|
# JOB 2: Deploy the built site to the web server
|
|
#----------------------------------------------------
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
steps:
|
|
# Step 1: Download the artifact from the 'build' job
|
|
- name: Download artifact
|
|
uses: actions/download-artifact@v3 # Use v3 instead of v4
|
|
with:
|
|
name: zola-public
|
|
|
|
# Step 2: Copy the files to the web server using SCP
|
|
- name: SCP files to server
|
|
uses: appleboy/scp-action@master
|
|
with:
|
|
host: ${{ secrets.SSH_HOST }}
|
|
username: ${{ secrets.SSH_USERNAME }}
|
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
source: "./*" # Copies the content of the downloaded artifact directory
|
|
target: "/var/www/html/finmoon" # The document root on your Apache server
|
|
strip_components: 1 # Removes the top-level directory from the source path
|
|
rm: true # Removes existing files in the target directory before copying |