From b622a9b57dea5a505af9558f50d1f1a3b1df46e8 Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Mon, 23 Dec 2024 00:15:24 +0100 Subject: [PATCH] ci: adapt for pull_request hook --- .forgejo/workflows/hugo.yaml | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/.forgejo/workflows/hugo.yaml b/.forgejo/workflows/hugo.yaml index 8abdc48..2167306 100644 --- a/.forgejo/workflows/hugo.yaml +++ b/.forgejo/workflows/hugo.yaml @@ -8,6 +8,8 @@ on: branches: - master - develop + pull_request: + types: [opened, synchronize, reopened] jobs: deploy: @@ -15,21 +17,24 @@ jobs: 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 - shell: /bin/bash run: | - if [[ "${{ env.github_ref_name }}" == "master" ]]; then + 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 + if [ "${{ env.github_ref_name }}" = "develop" ] + then echo "Using develop config" echo -n "https://preview.etoiledebethleem.fr" > /base_url.txt fi - ls / + ls -la /base_url.txt cat /base_url.txt - - name: Install rsync - run: apt update && apt install -y rsync - uses: actions/checkout@v4 with: submodules: true @@ -57,8 +62,13 @@ jobs: REMOTE_USER: forgejo_actions_websites SRV_HOST: srv06.lefuturiste.fr run: | - rsync --perms --archive --stats \ - -e 'ssh -i ~/.ssh/id_edsa -o StrictHostKeyChecking=no' ./public \ - $REMOTE_USER@$SRV_HOST:$OUTPUT_PATH$GITHUB_REF_NAME - + 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