196 lines
7.2 KiB
YAML
196 lines
7.2 KiB
YAML
name: Deploy Hugo Site
|
|
|
|
env:
|
|
TEA_VERSION: "0.10.1"
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches-ignore:
|
|
- "main"
|
|
paths:
|
|
- "**.md"
|
|
- "**.toml"
|
|
- "!config/_default/menus*.toml"
|
|
- "assets/**"
|
|
|
|
jobs:
|
|
check-and-create-pr:
|
|
if: github.ref != 'refs/heads/main'
|
|
name: Check and Create PR
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Gotify Notification
|
|
uses: eikendev/gotify-action@cb63800546f25c393ab96f09d12a094138c514f4 # master
|
|
with:
|
|
gotify_api_base: "${{ secrets.RUNNER_GOTIFY_URL }}"
|
|
gotify_app_token: "${{ secrets.RUNNER_GOTIFY_TOKEN }}"
|
|
notification_title: "GITEA: PR Check"
|
|
notification_message: "Checking for existing PR... 🔍"
|
|
|
|
- name: PR Check/Creation
|
|
uses: https://git.trez.wtf/Trez/gitea-auto-pr@main
|
|
with:
|
|
url: ${{ secrets.TREZ_GITEA_URL }}
|
|
token: ${{ secrets.BOT_GITEA_TOKEN }}
|
|
pr-label: hugo,manual
|
|
assignee: ${{ github.actor }}
|
|
|
|
- name: Gotify Notification
|
|
uses: eikendev/gotify-action@cb63800546f25c393ab96f09d12a094138c514f4 # master
|
|
with:
|
|
gotify_api_base: "${{ secrets.RUNNER_GOTIFY_URL }}"
|
|
gotify_app_token: "${{ secrets.RUNNER_GOTIFY_TOKEN }}"
|
|
notification_title: "GITEA: PR Check"
|
|
notification_message: "PR Check done 🎟️"
|
|
|
|
hugo-sanity-check:
|
|
name: Hugo Sanity Check
|
|
needs: [check-and-create-pr]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Gotify Notification
|
|
uses: eikendev/gotify-action@cb63800546f25c393ab96f09d12a094138c514f4 # master
|
|
with:
|
|
gotify_api_base: "${{ secrets.RUNNER_GOTIFY_URL }}"
|
|
gotify_app_token: "${{ secrets.RUNNER_GOTIFY_TOKEN }}"
|
|
notification_title: "GITEA: Hugo"
|
|
notification_message: "Starting link inspectionn... 🔍"
|
|
|
|
- name: Install Hugo
|
|
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0
|
|
with:
|
|
hugo-version: "latest"
|
|
# extended: true
|
|
|
|
- name: Verify Hugo install
|
|
run: |
|
|
hugo env
|
|
hugo version
|
|
|
|
- name: Linkinator
|
|
uses: JustinBeckwith/linkinator-action@3d5ba091319fa7b0ac14703761eebb7d100e6f6d # v1.11.0
|
|
with:
|
|
paths: .
|
|
serverRoot: ./
|
|
format: json
|
|
recurse: true
|
|
markdown: true
|
|
verbosity: error
|
|
|
|
- name: Gotify Notification
|
|
uses: eikendev/gotify-action@cb63800546f25c393ab96f09d12a094138c514f4 # master
|
|
with:
|
|
gotify_api_base: "${{ secrets.RUNNER_GOTIFY_URL }}"
|
|
gotify_app_token: "${{ secrets.RUNNER_GOTIFY_TOKEN }}"
|
|
notification_title: "GITEA: Hugo"
|
|
notification_message: "Broken link inspection done... 🔍"
|
|
|
|
pr-merge:
|
|
name: PR Merge
|
|
needs: [hugo-sanity-check]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
|
|
- name: Cache tea CLI
|
|
id: cache-tea
|
|
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
|
|
with:
|
|
path: /opt/hostedtoolcache/tea/${{ env.TEA_VERSION }}/x64
|
|
key: tea-${{ runner.os }}-${{ env.TEA_VERSION }}
|
|
|
|
- name: Install tea
|
|
uses: supplypike/setup-bin@8e3f88b4f143d9b5c3497f0fc12d45c83c123787 # v4.0.1
|
|
with:
|
|
uri: https://gitea.com/gitea/tea/releases/download/v${{ env.TEA_VERSION }}/tea-${{ env.TEA_VERSION }}-linux-amd64
|
|
name: tea
|
|
version: ${{ env.TEA_VERSION }}
|
|
|
|
- name: PR Merge
|
|
id: pr_merge
|
|
run: |
|
|
tea login add --name gitea-rinoa --url ${{ secrets.GITEA_URL }} --user gitea-sonarqube-bot --password "${{ secrets.BOT_GITEA_PASSWORD }}" --token ${{ secrets.BOT_GITEA_TOKEN }}
|
|
tea login default gitea-rinoa
|
|
echo "Merging PR..."
|
|
pr_index=$(tea pr ls --repo ${{ github.repository }} --state open --fields index,title,head,state --output csv | egrep ${{ github.ref_name }} | awk -F"," '{print $1}' | sed -e 's|"||g')
|
|
tea pr m --repo ${{ github.repository }} --title "Auto Merge of PR ${pr_index} - ${{ github.ref_name }}" --message "Merged by ${{ github.actor }}" ${pr_index}
|
|
echo "pr_index=${pr_index}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Gotify Notification
|
|
uses: eikendev/gotify-action@cb63800546f25c393ab96f09d12a094138c514f4 # master
|
|
with:
|
|
gotify_api_base: "${{ secrets.RUNNER_GOTIFY_URL }}"
|
|
gotify_app_token: "${{ secrets.RUNNER_GOTIFY_TOKEN }}"
|
|
notification_title: "GITEA: PR Merge Successful"
|
|
notification_message: "PR #${{ steps.pr_merge.outputs.pr_index }} merged."
|
|
|
|
deploy-hugo-site:
|
|
name: Build and Deploy to Server
|
|
needs: [hugo-sanity-check, pr-merge]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Setup Hugo
|
|
uses: peaceiris/actions-hugo@2752ce1d29631191ea3f27c23495fa06139a5b78 # v3
|
|
with:
|
|
hugo-version: "latest"
|
|
extended: true
|
|
|
|
- name: Setup rsync
|
|
id: setup_rsync
|
|
uses: GuillaumeFalourd/setup-rsync@c16d3c9077132c8ee28eb9de74edcb41c0e0e816 # v1.2
|
|
with:
|
|
ssh_key: ${{ secrets.VPS_DEPLOY_KEY }}
|
|
|
|
- name: Gotify Notification
|
|
uses: eikendev/gotify-action@cb63800546f25c393ab96f09d12a094138c514f4 # master
|
|
with:
|
|
gotify_api_base: "${{ secrets.RUNNER_GOTIFY_URL }}"
|
|
gotify_app_token: "${{ secrets.RUNNER_GOTIFY_TOKEN }}"
|
|
notification_title: "GITEA: Hugo"
|
|
notification_message: "Starting Hugo deployment... 🤞🏽"
|
|
|
|
- name: Generate Hugo Site & Deploy for Docker
|
|
env:
|
|
VPS_DEPLOY_USER: ${{ secrets.HUGO_DEPLOY_USERNAME }}
|
|
VPS_DEPLOY_HOST: ${{ secrets.HUGO_SITE_HOST }}
|
|
VPS_DEPLOY_DEST: ${{ secrets.VPS_DEPLOY_DEST }}
|
|
VPS_DEPLOY_KEY: ${{ steps.setup_rsync.outputs.ssh_key_path }}
|
|
run: |
|
|
hugo --minify --source .
|
|
rsync -e "ssh -i ${VPS_DEPLOY_KEY} -o StrictHostKeyChecking=no" -avz --progress ./public ${VPS_DEPLOY_USER}@192.168.1.254:${VPS_DEPLOY_DEST}
|
|
|
|
- name: Restart Hugo Container
|
|
uses: appleboy/ssh-action@0ff4204d59e8e51228ff73bce53f80d53301dee2 # v1.2.5
|
|
with:
|
|
host: 192.168.1.254
|
|
username: ${{ secrets.HUGO_DEPLOY_USERNAME }}
|
|
password: ${{ secrets.HUGO_DEPLOY_PASSWORD }}
|
|
key_path: ${{ steps.setup_rsync.outputs.ssh_key_path }}
|
|
script: |
|
|
docker container restart hugo
|
|
|
|
- name: Gotify Notification
|
|
uses: eikendev/gotify-action@cb63800546f25c393ab96f09d12a094138c514f4 # master
|
|
with:
|
|
gotify_api_base: "${{ secrets.RUNNER_GOTIFY_URL }}"
|
|
gotify_app_token: "${{ secrets.RUNNER_GOTIFY_TOKEN }}"
|
|
notification_title: "GITEA: Hugo"
|
|
notification_message: "Hugo deployment successful!"
|