Files
blog.raer.me/.gitea/workflows/production/build-deploy-docs.yml
Freyja Odinthrir a030e42d19
All checks were successful
/ Build static site, docker image, upload artifact... (push) Successful in 6m36s
/ Connect to deployment host, update, and redeploy docs website. (push) Successful in 21s
update workflow triggers, add a script to create a blog entry.
2024-10-26 03:11:18 -07:00

95 lines
2.7 KiB
YAML

on:
push:
paths:
- "content/**"
- "static/**"
- "templates/**"
- ".conf/**"
- ".gitea/**"
branches:
- "main"
jobs:
job1:
name: Build static site, docker image, upload artifact...
runs-on: catthehacker-ubuntu
steps:
-
name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')"
-
name: Checkout the git repo...
uses: https://github.com/actions/checkout@v3
-
name: Set up docker buildx...
uses: https://github.com/docker/setup-buildx-action@v3
-
name: Login to gitea registry
uses: https://github.com/docker/login-action@v3
with:
registry: gitea.raer.me
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
-
name: Install required system packages...
run: |
export DEBIAN_FRONTEND=noninteractive
apt update
apt upgrade -y
apt install -y curl tar p7zip-full python3.11 pip pipx
-
name: Install pipenv, build blog...
env:
PIPENV_USER: ${{ secrets.REGISTRY_USERNAME }}
PIPENV_PASS: ${{ secrets.REGISTRY_TOKEN }}
run: |
pip install pipenv
pipenv install
pipenv run blag build
-
name: Create artifact...
run: 7z a -mx=9 ./artifact.7z build
-
name: Upload artifact...
uses: https://github.com/actions/upload-artifact@v3
with:
name: artifact_${{ steps.date.outputs.date }}
path: ./artifact.7z
retention-days: 7
-
name: Build and push docker image to gitea package store
uses: https://github.com/docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/arm64
tags: gitea.raer.me/${{ gitea.repository }}:${{ gitea.ref_name }}
job2:
needs: job1
name: Connect to deployment host, update, and redeploy docs website.
runs-on: ubuntu-latest
steps:
-
name: Configure SSH...
env:
SSH_USER: ${{ secrets.DEPLOYMENT_USER }}
SSH_KEY: ${{ secrets.DEPLOYMENT_KEY }}
SSH_HOST: ${{ secrets.DEPLOYMENT_HOST }}
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/staging.key
chmod 600 ~/.ssh/staging.key
cat >> ~/.ssh/config <<END
Host staging
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/staging.key
StrictHostKeyChecking no
END
cat ~/.ssh/config
-
name: Run deploy script.
run: ssh staging