diff --git a/.gitea/pr-commenter.yml b/.gitea/pr-commenter.yml new file mode 100644 index 0000000..d96f23b --- /dev/null +++ b/.gitea/pr-commenter.yml @@ -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 }}* diff --git a/.gitea/workflows/jekyll.yaml b/.gitea/workflows/jekyll.yaml index 4d2a977..dc24ffa 100644 --- a/.gitea/workflows/jekyll.yaml +++ b/.gitea/workflows/jekyll.yaml @@ -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" diff --git a/.gitea/workflows/jekyll_cleanup.yml b/.gitea/workflows/jekyll_cleanup.yml new file mode 100644 index 0000000..74606dc --- /dev/null +++ b/.gitea/workflows/jekyll_cleanup.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} diff --git a/src/_includes/head/custom.html b/src/_includes/head/custom.html index 7c8dfb6..a1eb2e8 100644 --- a/src/_includes/head/custom.html +++ b/src/_includes/head/custom.html @@ -1,5 +1,5 @@ - + diff --git a/src/_posts/2020-09-08-welcome.md b/src/_posts/2020-09-08-welcome.md index ce89063..cce91e7 100644 --- a/src/_posts/2020-09-08-welcome.md +++ b/src/_posts/2020-09-08-welcome.md @@ -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 %} diff --git a/src/_posts/2020-09-09-post-1.md b/src/_posts/2020-09-09-post-1.md index 48f60a0..9f4c0e2 100644 --- a/src/_posts/2020-09-09-post-1.md +++ b/src/_posts/2020-09-09-post-1.md @@ -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 %} diff --git a/src/_posts/2020-09-09-post-2.md b/src/_posts/2020-09-09-post-2.md index 934085c..5342ecb 100644 --- a/src/_posts/2020-09-09-post-2.md +++ b/src/_posts/2020-09-09-post-2.md @@ -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 %} diff --git a/src/_posts/2020-09-09-post-3.md b/src/_posts/2020-09-09-post-3.md index f67d87a..73b2f3d 100644 --- a/src/_posts/2020-09-09-post-3.md +++ b/src/_posts/2020-09-09-post-3.md @@ -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 %} diff --git a/src/_sass/_custom.scss b/src/_sass/_custom.scss index d80b434..42ff92a 100644 --- a/src/_sass/_custom.scss +++ b/src/_sass/_custom.scss @@ -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 { @@ -44,4 +44,4 @@ h1, h2, h3, h4, h5, h6, .archive__item-title, .masthead__inner-wrap { .archive__item-excerpt { color: #a9862b; } -*/ \ No newline at end of file +*/ diff --git a/src/index.html b/src/index.html index f3d4db2..66e8f22 100644 --- a/src/index.html +++ b/src/index.html @@ -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:
- +

- {{ post.title }} + {{ post.title }}

{{ post.excerpt }}