fix wrong link #2369
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 | |
runs-on: ubuntu-latest | |
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 --endpoint-url https://s3.cern.ch s3 sync --delete build/${PR_NUMBER:-} ${DEST} | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: "eu-west-1" |