Do not delete important directories not part of the website when syncing #2441
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ROOT Web Publisher | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
env: | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
# only deploy if push to main or if pull request not coming from a fork (cannot access github secrets otherwise) | |
SHOULD_DEPLOY: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} | |
jobs: | |
build: | |
name: Jekyll Build | |
# Fix to ubuntu 22.04. In 2027, at the EOL of that distro, this GH warning will have to be addressed: | |
# The current runner (ubuntu-24.04-x64) was detected as self-hosted because the platform does not match a GitHub-hosted runner image (or that image is deprecated and no longer supported). | |
# In such a case, you should install Ruby in the $RUNNER_TOOL_CACHE yourself, for example using https://github.com/rbenv/ruby-build | |
# You can take inspiration from this workflow for more details: https://github.com/ruby/ruby-builder/blob/master/.github/workflows/build.yml | |
# $ ruby-build 3.1.4 /opt/hostedtoolcache/Ruby/3.1.4/x64 | |
# Once that completes successfully, mark it as complete with: | |
# $ touch /opt/hostedtoolcache/Ruby/3.1.4/x64.complete | |
# It is your responsibility to ensure installing Ruby like that is not done in parallel. | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 | |
with: | |
ruby-version: '3.1' # Not needed with a .ruby-version file | |
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
cache-version: 0 # Increment this number if you need to re-download cached gems | |
- name: Setup Pages | |
id: pages | |
uses: actions/configure-pages@v3 | |
- name: Build with Jekyll | |
# Outputs to the './build' directory by default | |
run: bundle exec jekyll build "${PR_NUMBER:+--baseurl=${PR_NUMBER}/}" --destination "build/${PR_NUMBER:-}" | |
env: | |
JEKYLL_ENV: production | |
- name: Only allow links to root.cern, never root.cern.ch | |
run: | | |
grep -n -R 'root\.cern\.ch' build || exit 0 # grep returns non-zero if no match is found | |
N_WRONG_LINKS=$(grep -R 'root\.cern\.ch' build | wc -l) | |
echo -e "\nFound $N_WRONG_LINKS links to root.cern.ch. Please change them to link to root.cern (no '.ch') instead." | |
exit 1 | |
- name: Only allow links to ref guide for master (except in release notes and when linking to release notes) | |
run: | | |
# grep for https://root.cern/doc/(!"master" && !"vXXX/release-notes.html"). If something is found, error out. | |
grep --exclude="index.html" --exclude-dir="releases" --exclude-dir="reference" --exclude-dir="all_releases" --exclude-dir="feed" -n -R -P 'https:\/\/root\.cern\/doc\/(?!(master|v[0-9]{3}\/release-notes\.html))' build \ | |
|| exit 0 # grep returns non-zero if no match is found | |
echo -e "\nFound links to /doc/NOT_MASTER (see above). Please change them to link to /doc/master." | |
exit 1 | |
- name: Wait for other deployments | |
# wait for other workflows that are deploying the website to finish, (not 100% foolproof, see #240) | |
if: ${{ env.SHOULD_DEPLOY == 'true' && github.event_name != 'pull_request' }} | |
uses: softprops/turnstyle@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Sync to S3 | |
if: ${{ env.SHOULD_DEPLOY == 'true' }} | |
run: | | |
DEST="s3://root/${PR_NUMBER:-}" # if PR, upload in s3://root/<prnumber> | |
aws configure set default.s3.max_concurrent_requests 200 | |
aws --endpoint-url https://s3.cern.ch s3 sync --delete build/${PR_NUMBER:-} ${DEST} --exclude 'files-test/*' --exclude 'download-test/*' --exclude 'doc-test/*' | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: "eu-west-1" |