Deploy preview in dedicated root with context per PR
Jekyll / jekyll (pull_request) Failing after 21s
Details
Jekyll / jekyll (pull_request) Failing after 21s
Details
Signed-off-by: Benoit Donneaux <benoit@leastauthority.com>
This commit is contained in:
parent
4d7cfaf6c3
commit
a0d865d21b
|
@ -6,13 +6,13 @@ comment:
|
|||
files:
|
||||
- '**'
|
||||
body: |
|
||||
#### :hammer: Docker image `{{ imageOutcome }}`
|
||||
#### :hammer: Docker build `{{ imageOutcome }}`
|
||||
|
||||
- id: build-{{ buildOutcome }}
|
||||
files:
|
||||
- '**'
|
||||
body: |
|
||||
#### :mag: Jekyll build `{{ buildOutcome }}`
|
||||
#### :wrench: Jekyll build `{{ buildOutcome }}`
|
||||
<details><summary>Build Output</summary>
|
||||
|
||||
```
|
||||
|
@ -26,7 +26,7 @@ comment:
|
|||
- '**'
|
||||
body: |
|
||||
#### :rocket: Jekyll deploy `{{ deployOutcome }}`
|
||||
#### :link: Preview documentation [here](https://www.lafs.eval.latfa.net/{{ deployPrefix}}/{{ deploySuffix }})
|
||||
#### :link: Preview site [here](https://{{ deployWebHost }}{{ deployWebContext }})
|
||||
|
||||
- id: pusher-{{ gitActor }}-{{ gitEventName }}-{{ gitRunNumber }}
|
||||
files:
|
||||
|
|
|
@ -8,8 +8,9 @@ on:
|
|||
env:
|
||||
_UID: 1000
|
||||
_GID: 1000
|
||||
PREFIX: site
|
||||
SUFFIX: preview
|
||||
WEB_DOMAIN: lafs.eval.latfa.net
|
||||
WEB_USER: www
|
||||
WEB_DIR: /var/www
|
||||
jobs:
|
||||
jekyll:
|
||||
runs-on: ubuntu-22.04
|
||||
|
@ -54,11 +55,23 @@ jobs:
|
|||
chmod 600 ~/.ssh/id_ed25519
|
||||
- name: Deploy Jekyll site
|
||||
id: deploy_site
|
||||
if: ${{ gitea.ref == 'refs/heads/main' }}
|
||||
run: |
|
||||
rsync -halvi \
|
||||
if [ "${{ gitea.ref }}" = 'refs/heads/main' ]; then
|
||||
WEB_ROOT="${WEB_DIR}/site"
|
||||
WEB_HOST="www.${WEB_DOMAIN}"
|
||||
WEB_CONTEXT='/'
|
||||
else
|
||||
WEB_ROOT="${WEB_DIR}/preview"
|
||||
WEB_HOST="preview.${WEB_DOMAIN}"
|
||||
WEB_CONTEXT='/{{ gitea.event.pull_request.number }}/'
|
||||
end
|
||||
# Save those variabes in the environment for the next steps
|
||||
echo "WEB_HOST=${WEB_HOST}" >> $GITEA_ENV
|
||||
echo "WEB_CONTEXT=${WEB_CONTEXT}" >> $GITEA_ENV
|
||||
# Synchronize the local and the remote site
|
||||
rsync -halvi --delete \
|
||||
-e "ssh -a -x -o StrictHostKeyChecking=no" \
|
||||
./_site/ www@lafs.eval.latfa.net:/var/www/site/
|
||||
"./_site/${WEB_USER}@${WEB_DOMAIN}:${WEB_ROOT}${WEB_CONTEXT}"
|
||||
- name: Comment pull request
|
||||
id: comment_pull_request
|
||||
if: gitea.event_name == 'pull_request'
|
||||
|
@ -70,8 +83,8 @@ jobs:
|
|||
"buildOutcome": "${{ steps.build_site.outcome }}",
|
||||
"buildOutputsResult": ${{ toJSON(steps.build_site.outputs.result) }},
|
||||
"deployOutcome": "${{ steps.deploy_site.outcome }}",
|
||||
"deployPrefix": "${{ env.PREFIX }}",
|
||||
"deploySuffix": "${{ env.SUFFIX }}",
|
||||
"deployWebHost": "${{ env.WEB_HOST }}",
|
||||
"deployWebContext": "${{ env.WEB_CONTEXT }}",
|
||||
"gitActor": "${{ gitea.actor }}",
|
||||
"gitEventName": "${{ gitea.event_name }}",
|
||||
"gitWorkflow": "${{ gitea.workflow }}",
|
||||
|
@ -83,5 +96,5 @@ jobs:
|
|||
id: fail-on-error
|
||||
if: |
|
||||
steps.build_site.outcome != 'success'
|
||||
|| (github.event_name == 'pull_request' && steps.deploy_site.outcome != 'success')
|
||||
|| (gittea.event_name == 'pull_request' && steps.deploy_site.outcome != 'success')
|
||||
run: exit 1
|
||||
|
|
Loading…
Reference in New Issue