website/.forgejo/workflows/hugo.yaml
Matthieu Bessat d6323b36c2
All checks were successful
Deploy workflow / deploy (pull_request) Successful in 30s
test forgejo action bash
2024-12-23 00:13:23 +01:00

75 lines
2.5 KiB
YAML

# 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
pull_request:
types: [opened, synchronize, reopened]
jobs:
deploy:
runs-on: docker
container:
image: code.forgejo.org/oci/node:20-bookworm
steps:
- name: Install rsync and bash
run: apt update && apt install -y rsync bash
- name: Set baseURL
run: |
echo "Checking current branch."
echo -n "https://dev.etoiledebethleem.fr" > /base_url.txt
if [ "${{ env.github_ref_name }}" = "master" ]
then
echo "Using master config"
echo -n "https://etoiledebethleem.fr" > /base_url.txt
fi
if [ "${{ env.github_ref_name }}" = "develop" ]
then
echo "Using develop config"
echo -n "https://preview.etoiledebethleem.fr" > /base_url.txt
fi
ls -la /base_url.txt
cat /base_url.txt
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Setup Hugo
env:
HUGO_RELEASE_TYPE: extended
HUGO_VERSION: 0.133.1
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
run: |
hugo --baseURL="$(cat /base_url.txt)"
- 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:
OUTPUT_PATH: "/warmd/etoiledebethleem/websites/main/"
REMOTE_USER: forgejo_actions_websites
SRV_HOST: srv06.lefuturiste.fr
run: |
if [ "${{ env.github_ref_name }}" = "master" ] || [ "${{ env.github_ref_name }}" = "develop" ]
then
echo "Deploying to $REMOTE_USER@$SRV_HOST:$OUTPUT_PATH$GITHUB_REF_NAME"
rsync --perms --archive --stats \
-e 'ssh -i ~/.ssh/id_edsa -o StrictHostKeyChecking=no' ./public \
$REMOTE_USER@$SRV_HOST:$OUTPUT_PATH$GITHUB_REF_NAME
else
echo "Deployment skipped."
fi