Deploy preview site to review pull requests #5
|
@ -0,0 +1,28 @@
|
|||
comment:
|
||||
glob-options:
|
||||
dot: true
|
||||
snippets:
|
||||
- id: image-{{ imageOutcome }}
|
||||
files:
|
||||
- '**'
|
||||
body: |
|
||||
#### :hammer: Docker build `{{ imageOutcome }}`
|
||||
|
||||
- id: build-{{ buildOutcome }}
|
||||
files:
|
||||
- '**'
|
||||
body: |
|
||||
#### :wrench: Jekyll build `{{ buildOutcome }}`
|
||||
|
||||
- id: deploy-{{ deployOutcome }}
|
||||
files:
|
||||
- '**'
|
||||
body: |
|
||||
#### :rocket: Jekyll deploy `{{ deployOutcome }}`
|
||||
#### :link: Preview site [here](https://{{ deployWebHost }}{{ deployWebContext }})
|
||||
|
||||
- id: pusher-{{ gitActor }}-{{ gitEventName }}-{{ gitRunNumber }}
|
||||
files:
|
||||
- '**'
|
||||
body: |
|
||||
*Pusher: @{{ gitActor }}, Action: `{{ gitEventName }}`, Workflow: `{{ gitWorkflow }}`, Run: {{ gitRunNumber }}*
|
|
@ -8,6 +8,9 @@ on:
|
|||
env:
|
||||
_UID: 1000
|
||||
_GID: 1000
|
||||
WEB_DOMAIN: lafs.eval.latfa.net
|
||||
WEB_USER: www
|
||||
WEB_DIR: /var/www
|
||||
jobs:
|
||||
jekyll:
|
||||
runs-on: ubuntu-22.04
|
||||
|
@ -41,18 +44,52 @@ jobs:
|
|||
- name: Build Jekyll site
|
||||
id: build_site
|
||||
run: |
|
||||
# Overwrite the baseurl for previewonly
|
||||
if [ "${{ gitea.event_name }}" = 'pull_request' ]; then
|
||||
echo "Overwriting baseurl for pull_request ${{ gitea.event.pull_request.number }}"
|
||||
sed -i -r -e 's/^baseurl:\s*"([^"]*)"/baseurl: "\1\/${{ gitea.event.pull_request.number }}"/' _config.yml
|
||||
grep "^baseurl:" _config.yml
|
||||
fi
|
||||
docker-compose run --rm -v "${JOB_CONTAINER_NAME}:/site" -w /site \
|
||||
jekyll build --verbose
|
||||
- name: Prepare ssh key
|
||||
id: prepare_ssh_key
|
||||
if: ${{ gitea.ref == 'refs/heads/main' }}
|
||||
- name: Deploy Jekyll site
|
||||
id: deploy_site
|
||||
run: |
|
||||
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 }}/'
|
||||
fi
|
||||
# Save those variabes in the environment for the next steps
|
||||
echo "WEB_HOST=${WEB_HOST}" >> $GITHUB_ENV
|
||||
echo "WEB_CONTEXT=${WEB_CONTEXT}" >> $GITHUB_ENV
|
||||
# Prepare ssh key
|
||||
echo "${{ secrets.WWW_DEPLOY_KEY }}" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
- name: Publish Jekyll site
|
||||
id: publish_site
|
||||
if: ${{ gitea.ref == 'refs/heads/main' }}
|
||||
run: |
|
||||
rsync -halvi \
|
||||
# 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: ${{ always() && gitea.event_name == 'pull_request' }}
|
||||
uses: exercism/pr-commenter-action@v1.5.1
|
||||
with:
|
||||
template-variables: |
|
||||
{
|
||||
"imageOutcome": "${{ steps.build_image.outcome }}",
|
||||
"buildOutcome": "${{ steps.build_site.outcome }}",
|
||||
"deployOutcome": "${{ steps.deploy_site.outcome }}",
|
||||
"deployWebHost": "${{ env.WEB_HOST }}",
|
||||
"deployWebContext": "${{ env.WEB_CONTEXT }}",
|
||||
"gitActor": "${{ gitea.actor }}",
|
||||
"gitEventName": "${{ gitea.event_name }}",
|
||||
"gitWorkflow": "${{ gitea.workflow }}",
|
||||
"gitRunNumber": "${{ gitea.run_number }}",
|
||||
"gitRunAttempt": "${{ gitea.run_attempt }}"
|
||||
}
|
||||
config-file: ".gitea/pr-commenter.yml"
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
name: Jekyll cleanup
|
||||
|
||||
# only trigger on pull request closed events
|
||||
on:
|
||||
pull_request:
|
||||
types: [ closed ]
|
||||
|
||||
env:
|
||||
WEB_DOMAIN: lafs.eval.latfa.net
|
||||
WEB_USER: www
|
||||
WEB_ROOT: /var/www/preview
|
||||
WEB_CONTEXT: "/${{ gitea.event.pull_request.number }}/"
|
||||
jobs:
|
||||
jekyll_cleanup:
|
||||
runs-on: ubuntu-22.04
|
||||
permissions:
|
||||
pull-requests: write
|
||||
actions: read
|
||||
contents: read
|
||||
steps:
|
||||
- name: Cleanup Jeyll preview
|
||||
id: cleanup_preview
|
||||
run: |
|
||||
# Prepare ssh key
|
||||
echo "${{ secrets.WWW_DEPLOY_KEY }}" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
# Delete preview context from the remote site
|
||||
sudo apt install -y lftp
|
||||
echo -e "set sftp:connect-program ssh -a -x -o StrictHostKeyChecking=no; rm -r -f ${WEB_ROOT}${WEB_CONTEXT}\nbye" \
|
||||
| lftp sftp://${WEB_USER}:unused@${WEB_DOMAN}
|
|
@ -1,5 +1,5 @@
|
|||
<!-- start custom head snippets -->
|
||||
|
||||
<link href="/assets/images/favicon.ico" rel="shortcut icon" type="image/x-icon">
|
||||
<link href="assets/images/favicon.ico" rel="shortcut icon" type="image/x-icon">
|
||||
|
||||
<!-- end custom head snippets -->
|
||||
|
|
|
@ -6,7 +6,7 @@ excerpt: "Welcome to Dummy Jekyll"
|
|||
header:
|
||||
teaser: /assets/images/posts/unsplash-welcome.jpg
|
||||
gallery:
|
||||
- image_path: assets/images/posts/unsplash-welcome.jpg
|
||||
- image_path: /assets/images/posts/unsplash-welcome.jpg
|
||||
alt: "welcome"
|
||||
---
|
||||
{% include gallery %}
|
||||
|
|
|
@ -6,7 +6,7 @@ excerpt: "This is a generic post."
|
|||
header:
|
||||
teaser: /assets/images/posts/unsplash-post.jpg
|
||||
gallery:
|
||||
- image_path: assets/images/posts/unsplash-post.jpg
|
||||
- image_path: /assets/images/posts/unsplash-post.jpg
|
||||
alt: "post"
|
||||
---
|
||||
{% include gallery %}
|
||||
|
|
|
@ -6,7 +6,7 @@ excerpt: "This is a generic post."
|
|||
header:
|
||||
teaser: /assets/images/posts/unsplash-post.jpg
|
||||
gallery:
|
||||
- image_path: assets/images/posts/unsplash-post.jpg
|
||||
- image_path: /assets/images/posts/unsplash-post.jpg
|
||||
alt: "post"
|
||||
---
|
||||
{% include gallery %}
|
||||
|
|
|
@ -6,7 +6,7 @@ excerpt: "This is a generic post."
|
|||
header:
|
||||
teaser: /assets/images/posts/unsplash-post.jpg
|
||||
gallery:
|
||||
- image_path: assets/images/posts/unsplash-post.jpg
|
||||
- image_path: /assets/images/posts/unsplash-post.jpg
|
||||
alt: "post"
|
||||
---
|
||||
{% include gallery %}
|
||||
|
|
|
@ -12,24 +12,24 @@
|
|||
}*/
|
||||
/*
|
||||
.page__hero--overlay {
|
||||
background: url(/assets/images/pattern-4.gif) repeat left top;
|
||||
background: url(../images/pattern-4.gif) repeat left top;
|
||||
}
|
||||
*/
|
||||
.initial-content {
|
||||
//position: relative;
|
||||
//top: 70px;
|
||||
background: url(/assets/images/pattern-1.png) repeat left top;
|
||||
background: url(../images/pattern-1.png) repeat left top;
|
||||
}
|
||||
/*
|
||||
#about {
|
||||
background: url(/assets/images/pattern-2.gif) repeat left top;
|
||||
background: url(../images/pattern-2.gif) repeat left top;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "homestead_regularregular";
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
src: url("/assets/fonts/homestead-regular-webfont.woff") format("woff");
|
||||
src: url("../fonts/homestead-regular-webfont.woff") format("woff");
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6, .archive__item-title, .masthead__inner-wrap {
|
||||
|
|
|
@ -24,7 +24,7 @@ documentation_list:
|
|||
url: "https://tahoe-lafs.readthedocs.io/en/latest/about-tahoe.html"
|
||||
btn_label: "Read More"
|
||||
btn_class: "btn--primary"
|
||||
- image_path: assets/images/manual.jpg
|
||||
- image_path: /assets/images/manual.jpg
|
||||
image_caption: "Image courtesy of [Unsplash](https://unsplash.com/)"
|
||||
alt: "manual"
|
||||
title: "Manual"
|
||||
|
@ -44,7 +44,7 @@ contribute:
|
|||
- title: "Get Involved"
|
||||
excerpt: ""
|
||||
contribute_list:
|
||||
- image_path: assets/images/mailing.jpg
|
||||
- image_path: /assets/images/mailing.jpg
|
||||
image_caption: "Image courtesy of [Unsplash](https://unsplash.com/)"
|
||||
alt: "mailing"
|
||||
title: "Mailing list"
|
||||
|
@ -96,10 +96,10 @@ about:
|
|||
<div class="grid__item">
|
||||
<article class="archive__item" itemscope itemtype="https://schema.org/CreativeWork">
|
||||
<div class="archive__item-teaser">
|
||||
<img src="{{post.header.teaser}}" alt="">
|
||||
<img src="{{ post.header.teaser | relative_url }}" alt="">
|
||||
</div>
|
||||
<h2 class="archive__item-title" itemprop="headline">
|
||||
<a href="{{ post.url }}" rel="permalink">{{ post.title }}</a>
|
||||
<a href="{{ post.url | relative_url }}" rel="permalink">{{ post.title }}</a>
|
||||
</h2>
|
||||
<p class="archive__item-excerpt" itemprop="description">{{ post.excerpt }}</p>
|
||||
</article>
|
||||
|
|
Loading…
Reference in New Issue