Skip to content

Commit 2ac421e

Browse files
authored
Merge pull request #246 from r-devel/workflows/docs
try manual deploy vs mkdocs deploy
2 parents 0717077 + 3647457 commit 2ac421e

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

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

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ jobs:
1414
build-and-deploy:
1515
if: |
1616
github.event_name == 'workflow_dispatch' ||
17-
(github.event_name == 'pull_request' && github.event.pull_request.merged == true)
17+
(github.event_name == 'pull_request' &&
18+
github.event.pull_request.merged == true)
1819
runs-on: ubuntu-latest
1920
permissions:
2021
contents: write
@@ -36,16 +37,19 @@ jobs:
3637
run: |
3738
if [[ "${{ github.ref_name }}" == "main" ]]; then
3839
echo "target_repo=${{ github.repository }}" >> "$GITHUB_OUTPUT"
39-
echo "url=https://contributor.r-project.org/r-dev-env" >> "$GITHUB_OUTPUT"
40+
echo "url=https://contributor.r-project.org/r-dev-env" \
41+
>> "$GITHUB_OUTPUT"
4042
else
4143
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"
44+
echo "url=https://contributor.r-project.org/r-dev-env-devel" \
45+
>> "$GITHUB_OUTPUT"
4346
fi
4447
4548
- name: Modify site_url in mkdocs.yml
4649
run: |
4750
echo "Setting site_url to ${{ steps.config.outputs.url }}"
48-
sed -i "s|^site_url:.*|site_url: '${{ steps.config.outputs.url }}'|" mkdocs.yml
51+
sed -i "s|^site_url:.*|site_url: '${{
52+
steps.config.outputs.url }}'|" mkdocs.yml
4953
5054
- name: Build MkDocs
5155
run: mkdocs build
@@ -54,9 +58,10 @@ jobs:
5458
env:
5559
GH_PAT: ${{ secrets.R_DEV_ENV_DOCS }}
5660
run: |
57-
curl -H "Authorization: token $GH_PAT" https://api.github.com/user || {
58-
echo "PAT is invalid or expired" >&2
59-
exit 1
61+
curl -H "Authorization: token $GH_PAT" \
62+
https://api.github.com/user || {
63+
echo "PAT is invalid or expired" >&2
64+
exit 1
6065
}
6166
6267
- name: Deploy to GitHub Pages
@@ -65,7 +70,15 @@ jobs:
6570
run: |
6671
echo "Deploying from branch: ${{ github.ref_name }}"
6772
echo "Commit: ${{ github.sha }}"
68-
git config --global credential.helper store
69-
echo "https://x-access-token:${GH_PAT}@github.com" > ~/.git-credentials
70-
git remote set-url origin https://github.com/${{ steps.config.outputs.target_repo }}
71-
mkdocs gh-deploy --config-file mkdocs.yml --remote-branch gh-pages --force
73+
74+
git config --global user.email "[email protected]"
75+
git config --global user.name "github-actions"
76+
77+
git worktree add gh-pages gh-pages
78+
cp -r site/* gh-pages/
79+
cd gh-pages
80+
git add .
81+
git commit -m "Automated site update for r-dev-env ${{ github.sha }}" \
82+
|| echo "No changes to commit"
83+
git push https://x-access-token:${GH_PAT}@github.com/${{
84+
steps.config.outputs.target_repo }} gh-pages

0 commit comments

Comments
 (0)