Skip to content

use different url when deploying from devel vs main #53

use different url when deploying from devel vs main

use different url when deploying from devel vs main #53

name: Build MKDocs website
on:
workflow_dispatch:
pull_request:
branches: ["main","devel"]
types: [closed]
paths:
- 'build-mkdocs-website.yml'
- 'docs/**/**'
- 'mkdocs.yml'
jobs:
build-and-deploy:
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: pip install mkdocs mkdocs-material[imaging]
- name: Determine deployment path
id: path
run: |
if [[ "${{ github.ref_name }}" == "main" ]]; then
echo "url=https://contributor.r-project.org/r-dev-env" >> "$GITHUB_OUTPUT"
else
echo "url=https://contributor.r-project.org/r-dev-env/devel" >> "$GITHUB_OUTPUT"
fi
- name: Modify site_url in mkdocs.yml
run: |
echo "Setting site_url to ${{ steps.path.outputs.url }}"
sed -i "s|^site_url:.*|site_url: '${{ steps.path.outputs.url }}'|" mkdocs.yml
- name: Build MkDocs
run: mkdocs build
- name: Deploy to GitHub Pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}
mkdocs gh-deploy --force
git push origin gh-pages