Some checks failed
Build and Deploy Hugo Site / build_and_deploy (push) Failing after 13s
85 lines
2.3 KiB
YAML
85 lines
2.3 KiB
YAML
name: Build and Deploy Hugo Site
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build_and_deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2.4.0
|
|
- name: Set Environment
|
|
id: set-env
|
|
run: |
|
|
# Ensure the deploy_env.json file exists and is readable
|
|
if [ ! -f deploy_env.json ]; then
|
|
echo "deploy_env.json does not exist or cannot be read."
|
|
exit 1
|
|
fi
|
|
|
|
# Extract the environment variable using jq and check if it's empty
|
|
ENV=$(cat deploy_env.json | jq -r '.env')
|
|
if [ -z "$ENV" ]; then
|
|
echo "Environment variable is empty."
|
|
exit 1
|
|
fi
|
|
|
|
# Use GitHub's environment file syntax to set the ENV variable
|
|
echo "ENV=$ENV" >> $GITHUB_ENV
|
|
|
|
# Output the environment variable for use in subsequent steps
|
|
echo "::set-output name=environment::$ENV"
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5.0.0
|
|
with:
|
|
go-version: '1.20.5'
|
|
|
|
- name: Cache Go modules
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4.0.2
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: Cache Node modules
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-
|
|
|
|
- name: Install PostCSS
|
|
run: |
|
|
npm install -g postcss postcss-cli
|
|
npm install autoprefixer
|
|
|
|
- name: Set up Hugo Extended
|
|
uses: peaceiris/actions-hugo@v3.0.0
|
|
with:
|
|
hugo-version: '0.121.2'
|
|
extended: true
|
|
|
|
- name: Build Hugo site
|
|
run: hugo --minify
|
|
|
|
- name: Deploy to Server
|
|
if: ${{ github.job.outputs.environment == 'development' }}
|
|
uses: SamKirkland/FTP-Deploy-Action@4.0.0
|
|
with:
|
|
protocol: ftps
|
|
server: ${{ secrets.FTP_SERVER }}
|
|
username: ${{ secrets.FTP_USERNAME }}
|
|
password: ${{ secrets.FTP_PASSWORD }}
|
|
local-dir: public/
|
|
server-dir: '/'
|