Skip to content

Commit acdda21

Browse files
committed
deploy devel docs to r-dev-devel repo
1 parent 2b0fc2b commit acdda21

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

.github/workflows/build-mkdocs-website.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,39 @@ jobs:
3131
- name: Install dependencies
3232
run: pip install mkdocs mkdocs-material[imaging]
3333

34-
- name: Determine deployment path
35-
id: path
34+
- name: Determine deployment settings
35+
id: config
3636
run: |
3737
if [[ "${{ github.ref_name }}" == "main" ]]; then
38+
echo "target_repo=${{ github.repository }}" >> "$GITHUB_OUTPUT"
3839
echo "url=https://contributor.r-project.org/r-dev-env" >> "$GITHUB_OUTPUT"
3940
else
40-
echo "url=https://contributor.r-project.org/r-dev-env/devel" >> "$GITHUB_OUTPUT"
41+
echo "target_repo=r-devel/r-dev-env-devel" >> "$GITHUB_OUTPUT"
42+
echo "url=https://contributor.r-project.org/r-dev-env-devel" >> "$GITHUB_OUTPUT"
4143
fi
4244
4345
- name: Modify site_url in mkdocs.yml
4446
run: |
45-
echo "Setting site_url to ${{ steps.path.outputs.url }}"
46-
sed -i "s|^site_url:.*|site_url: '${{ steps.path.outputs.url }}'|" mkdocs.yml
47-
47+
echo "Setting site_url to ${{ steps.config.outputs.url }}"
48+
sed -i "s|^site_url:.*|site_url: '${{ steps.config.outputs.url }}'|" mkdocs.yml
4849
4950
- name: Build MkDocs
5051
run: mkdocs build
5152

53+
- name: Validate PAT
54+
env:
55+
GH_PAT: ${{ secrets.R_DEV_ENV_DOCS }}
56+
run: |
57+
curl -H "Authorization: token $GH_PAT" https://api.github.com/user || {
58+
echo "PAT is invalid or expired" >&2
59+
exit 1
60+
}
61+
5262
- name: Deploy to GitHub Pages
5363
env:
54-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
GH_PAT: ${{ secrets.R_DEV_ENV_DOCS }}
5565
run: |
56-
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}
57-
mkdocs gh-deploy --force
58-
git push origin gh-pages
66+
echo "Deploying from branch: ${{ github.ref_name }}"
67+
echo "Commit: ${{ github.sha }}"
68+
git remote set-url origin https://x-access-token:${GH_PAT}@github.com/${{ steps.config.outputs.target_repo }}
69+
mkdocs gh-deploy --config-file mkdocs.yml --remote-branch gh-pages --force

0 commit comments

Comments
 (0)