website/.forgejo/workflows/hugo.yaml

70 lines
2.2 KiB
YAML
Raw Normal View History

2024-03-10 16:38:20 +00:00
# deploy on branch (only on master and develop)
# on develop -> will deploy on preview.etoiledebethleem.fr
# on master -> will deploy on etoiledebethleem.fr
name: Deploy workflow
on:
push:
branches:
- master
- develop
2024-12-22 22:53:37 +00:00
pull_request:
types: [opened, synchronize, reopened]
2024-03-10 16:38:20 +00:00
jobs:
deploy:
runs-on: docker
2024-03-10 16:48:21 +00:00
container:
image: code.forgejo.org/oci/node:20-bookworm
2024-03-10 16:38:20 +00:00
steps:
2024-12-22 23:02:28 +00:00
- name: Install rsync and bash
run: apt update && apt install -y rsync bash
2024-03-10 22:51:44 +00:00
- name: Set baseURL
run: |
2024-12-22 23:01:39 +00:00
echo "Checking current branch."
echo -n "https://dev.etoiledebethleem.fr" > /base_url.txt
2024-12-22 23:06:06 +00:00
if [ "${{ env.github_ref_name }}" = "master" ]
then
2024-03-18 19:56:51 +00:00
echo "Using master config"
2024-03-10 22:51:44 +00:00
echo -n "https://etoiledebethleem.fr" > /base_url.txt
fi
2024-12-22 23:06:06 +00:00
if [ "${{ env.github_ref_name }}" = "develop" ]
then
2024-03-18 19:56:51 +00:00
echo "Using develop config"
2024-03-10 22:51:44 +00:00
echo -n "https://preview.etoiledebethleem.fr" > /base_url.txt
fi
2024-12-22 23:06:06 +00:00
ls -la /base_url.txt
2024-03-18 19:56:51 +00:00
cat /base_url.txt
2024-03-10 16:38:20 +00:00
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Setup Hugo
env:
HUGO_RELEASE_TYPE: extended
2024-10-04 18:24:15 +00:00
HUGO_VERSION: 0.133.1
2024-03-10 16:38:20 +00:00
run: |
mkdir ~/hugo
cd ~/hugo
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
tar -xvzf hugo.tar.gz
mv hugo /usr/local/bin
- name: Build
2024-03-10 22:51:44 +00:00
run: |
hugo --baseURL="$(cat /base_url.txt)"
2024-03-10 16:38:20 +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-03-10 16:48:21 +00:00
OUTPUT_PATH: "/warmd/etoiledebethleem/websites/main/"
2024-03-10 16:38:20 +00:00
REMOTE_USER: forgejo_actions_websites
SRV_HOST: srv06.lefuturiste.fr
run: |
2024-03-10 22:51:44 +00:00
rsync --perms --archive --stats \
2024-03-10 16:38:20 +00:00
-e 'ssh -i ~/.ssh/id_edsa -o StrictHostKeyChecking=no' ./public \
2024-03-10 16:48:21 +00:00
$REMOTE_USER@$SRV_HOST:$OUTPUT_PATH$GITHUB_REF_NAME
2024-03-10 16:38:20 +00:00