website/.forgejo/workflows/hugo.yaml

62 lines
1.9 KiB
YAML
Raw Normal View History

2024-11-24 17:46:17 +00:00
name: Deploy workflow
on:
push:
branches:
- master
- develop
2023-11-06 19:59:07 +00:00
jobs:
2024-11-24 17:46:17 +00:00
deploy:
2023-11-06 19:59:07 +00:00
runs-on: docker
2024-04-13 12:24:27 +00:00
container:
image: code.forgejo.org/oci/node:20-bookworm
2023-11-06 19:59:07 +00:00
steps:
2024-11-24 17:46:17 +00:00
- name: Set baseURL
shell: /bin/bash
run: |
if [[ "${{ env.github_ref_name }}" == "master" ]]; then
echo "Using master config"
echo -n "https://bicycleure.fr" > /base_url.txt
fi
if [[ "${{ env.github_ref_name }}" == "develop" ]]; then
echo "Using develop config"
echo -n "https://develop.bicycleure.fr" > /base_url.txt
fi
ls /
cat /base_url.txt
2023-11-06 19:59:07 +00:00
- name: Install rsync
run: apt update && apt install -y rsync
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Setup Hugo
env:
HUGO_RELEASE_TYPE: extended
2024-11-24 17:46:17 +00:00
HUGO_VERSION: 0.133.1
2023-11-06 19:59:07 +00:00
run: |
mkdir ~/hugo
cd ~/hugo
2024-11-24 17:46:17 +00:00
curl -L \
"https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_RELEASE_TYPE}_${HUGO_VERSION}_Linux-64bit.tar.gz" \
--output hugo.tar.gz
2023-11-06 19:59:07 +00:00
tar -xvzf hugo.tar.gz
2024-11-24 17:46:17 +00:00
mv hugo /usr/local/bin
2023-11-06 19:59:07 +00:00
- name: Build
2024-11-24 17:46:17 +00:00
run: |
hugo --baseURL="$(cat /base_url.txt)"
2023-11-06 19:59:07 +00:00
- name: Create Key File
run: install -m 600 -D /dev/null ~/.ssh/id_edsa
- name: Populate Key
run: echo "${{ secrets.SRV06_DEPLOY_WEBSITE_SSH_KEY }}" > ~/.ssh/id_edsa
- name: Upload
env:
2024-11-24 17:46:17 +00:00
OUTPUT_PATH: "/warmd/mbess/bicycleure/website_prod"
2023-11-06 19:59:07 +00:00
REMOTE_USER: forgejo_actions_websites
SRV_HOST: srv06.lefuturiste.fr
run: |
2024-11-24 17:46:17 +00:00
rsync -r --stats --compress \
2023-11-07 22:09:03 +00:00
-e 'ssh -i ~/.ssh/id_edsa -o StrictHostKeyChecking=no' ./public \
2024-11-24 17:46:17 +00:00
$REMOTE_USER@$SRV_HOST:$OUTPUT_PATH$GITHUB_REF_NAME