Skip to content

Commit 1d50ff2

Browse files
committed
refactor: rewrite docs workflow file
1 parent 3c434f7 commit 1d50ff2

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

.github/workflows/publish-docs.yml

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: documentation
1+
name: Documentation
22

33
on:
44
pull_request_target:
@@ -11,33 +11,45 @@ permissions:
1111

1212
jobs:
1313
docs:
14-
if: ${{ github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' }} || ${{ github.event_name == 'workflow_dispatch' }}
14+
name: Build and Publish Docs
15+
if: |
16+
(github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main') ||
17+
github.event_name == 'workflow_dispatch'
1518
runs-on: [self-hosted, nvidia]
1619
steps:
17-
- uses: actions/checkout@v5
18-
- uses: actions/setup-python@v6
20+
- name: Checkout repository
21+
uses: actions/checkout@v5
1922
with:
20-
python-version: '3.10'
23+
fetch-depth: 0
24+
submodules: recursive
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v6
28+
with:
29+
python-version: "3.10"
30+
2131
- name: Build docs
2232
run: |
23-
chmod +x ./maint/scripts/build_docs.sh
24-
./maint/scripts/build_docs.sh
25-
- name: Push to another repo
26-
env:
27-
TARGET_REPO: ${{ secrets.TARGET_REPO }}
28-
TARGET_TOKEN: ${{ secrets.TARGET_TOKEN }}
33+
bash -ex maint/scripts/build_docs.sh
34+
35+
- name: Push built docs to another repo
2936
run: |
30-
git clone https://github.com/${TARGET_REPO}.git -b main target_repo
37+
# Hide sensitive info in logs
38+
echo "::add-mask::${{ secrets.TARGET_TOKEN }}"
39+
echo "::add-mask::${{ secrets.TARGET_REPO }}"
40+
TARGET_REPO_URL="https://github.com/${{ secrets.TARGET_REPO }}.git"
41+
42+
git clone "${TARGET_REPO_URL}" -b main target_repo
3143
cd target_repo
3244
git config --local user.name "github-actions[bot]"
3345
git config --local user.email "github-actions[bot]@users.noreply.github.com"
3446
find . -mindepth 1 -maxdepth 1 ! -name ".github" ! -name "." ! -name ".git" -exec rm -rf {} +
3547
cp -r ../docs/_build/html/* ./
3648
git add .
3749
if [[ -n "$(git status --porcelain)" ]]; then
38-
# If there are changes, commit and push
50+
# If there are changes, commit and push
3951
git commit -m "Update docs"
40-
git push https://github-actions[bot]:$TARGET_TOKEN@github.com/${TARGET_REPO}.git main
52+
git push "https://github-actions[bot]:${{ secrets.TARGET_TOKEN }}@${TARGET_REPO_URL##*://}" main
4153
else
4254
echo "No changes detected, skipping commit and push."
4355
fi

0 commit comments

Comments
 (0)