Skip to content

Build, validate & publish page #22482

Build, validate & publish page

Build, validate & publish page #22482

name: Build, validate & publish page
on:
schedule:
- cron: '0 */1 * * *'
push:
branches:
- gh-pages
pull_request:
branches:
- gh-pages
workflow_dispatch:
jobs:
build-validate-and-publish:
name: Publish to Github Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
path: src
- uses: actions/checkout@v2
with:
path: live
ref: master
- name: 🐍 Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: "3.7"
- name: 🐍 Install requirements
run: |
pip install -r ./src/.github/scripts/requirements.txt
- name: πŸ“Ί Refresh youtube thumbnails
run: |
cd src
chmod +x .github/scripts/fetch_yt_preview
.github/scripts/fetch_yt_preview
- name: πŸ•΅οΈβ€β™‚ Validate front matter
run: |
cd src
python .github/scripts/validate_front_matter.py --action-output
- name: πŸ— Enrich front matter
if: github.repository == 'OctoPrint/plugins.octoprint.org' && github.event_name != 'pull_request'
run: |
python ./src/.github/scripts/populate_additional_metadata.py
env:
GITHUB_TOKEN: ${{ secrets.metadata_token }}
- name: πŸ— Enrich notices
if: github.repository == 'OctoPrint/plugins.octoprint.org' && github.event_name != 'pull_request'
run: |
python ./src/.github/scripts/populate_additional_notices.py
env:
GITHUB_TOKEN: ${{ secrets.metadata_token }}
- name: πŸ— Enrich py2 check overlays
if: github.repository == 'OctoPrint/plugins.octoprint.org' && github.event_name != 'pull_request'
run: |
python ./src/.github/scripts/populate_py2_overlays.py
- name: πŸ“¦ Cache jekyll build bundle
uses: actions/cache@v2
with:
path: ./bundle
key: ${{ runner.os }}-jekyll-build-bundle
- name: πŸ”¨ Build page
run: |
docker run \
-v ${{ github.workspace }}/src:/srv/jekyll \
-v ${{ github.workspace }}/bundle:/usr/local/bundle \
jekyll/builder:3.8.6 /bin/bash -c "chmod 777 /srv/jekyll && jekyll build --trace --future --strict_front_matter"
- name: πŸ”„ Prepare live copy
run: |
rm -rf live/* || true
touch live/.nojekyll
cp -r src/_site/* live
- name: πŸ”Ž Determine changed files
id: changed
run: |
cd live
git diff --name-only
changed=($(git diff --name-only))
json=`printf '%s\n' "${changed[@]}" | jq -R . | jq -c -s .`
echo "::set-output name=files::$json"
- name: πŸ•΅οΈβ€β™‚οΈ Validate plugins.json
if: contains( fromJSON( steps.changed.outputs.files ), 'plugins.json' )
run: |
docker run \
-v ${{ github.workspace }}/live:/json \
peterdavehello/jsonlint jsonlint -q /json/plugins.json
- name: πŸ•΅οΈβ€β™‚οΈ Validate notices.json
if: contains( fromJSON( steps.changed.outputs.files ), 'notices.json' )
run: |
docker run \
-v ${{ github.workspace }}/live:/json \
peterdavehello/jsonlint jsonlint -q /json/notices.json
- name: πŸ•΅οΈβ€β™‚οΈ Validate search.json
if: contains( fromJSON( steps.changed.outputs.files ), 'search.json' )
run: |
docker run \
-v ${{ github.workspace }}/live:/json \
peterdavehello/jsonlint jsonlint -q /json/search.json
#- name: πŸ•΅οΈβ€β™‚οΈ Run link check
# run: |
# docker run \
# -v ${{ github.workspace }}/_site:/mounted-site \
# mtlynch/htmlproofer /mounted-site --only-4xx --check-favicon --check-html --file-ignore '/\/mounted-site\/search\/index\.php/,/\/mounted-site\/by_(author|tag|date|name)\/index\.html/' --log-level ':debug'
#- name: πŸ•΅οΈβ€β™‚οΈ Run link check
# id: lc
# uses: peter-evans/link-checker@v1
# with:
# args: -v -r -d ./_site/ ./_site/
#- name: πŸ•΅οΈβ€β™‚οΈ Evaluate link check
# run: exit ${{ steps.lc.outputs.exit_code }}
- name: πŸš€ Commit & deploy
if: github.repository == 'OctoPrint/plugins.octoprint.org' && github.event_name != 'pull_request'
uses: EndBug/add-and-commit@v4
with:
cwd: "live"
ref: "master"
message: "deploy: ${{ github.sha }}"
author_name: 'github-actions[bot]'
author_email: 'github-actions[bot]@users.noreply.github.com'
- name: πŸ“§ Discord success notification
if: github.repository == 'OctoPrint/plugins.octoprint.org' && github.event_name != 'pull_request'
env:
DISCORD_WEBHOOK: ${{ secrets.discord_webhook }}
uses: Ilshidur/action-discord@master
with:
args: 'β˜‘οΈ Page build for plugins.octoprint.org was successful'
- name: πŸ“§ Discord failure notification
if: failure() && github.repository == 'OctoPrint/plugins.octoprint.org' && github.event_name != 'pull_request'
env:
DISCORD_WEBHOOK: ${{ secrets.discord_webhook }}
uses: Ilshidur/action-discord@master
with:
args: '🚫 Page build for plugins.octoprint.org failed'