@@ -22,22 +22,13 @@ jobs:
2222 runs-on : ubuntu-latest
2323 permissions :
2424 contents : write
25+ pull-requests : write
2526 steps :
2627 - name : Checkout code
2728 uses : actions/checkout@v4
2829 with :
2930 fetch-depth : 1
3031
31- - name : Set up Python
32- uses : actions/setup-python@v4
33- with :
34- python-version : ' 3.11'
35-
36- - name : Install dependencies
37- run : |
38- cd python
39- pip install -e .[docs-build]
40-
4132 - name : Extract version
4233 id : version
4334 run : |
@@ -56,21 +47,41 @@ jobs:
5647 echo "alias=$ALIAS" >> $GITHUB_OUTPUT
5748 echo "Dev deployment - Version: $VERSION, Alias: $ALIAS"
5849
59- - name : Fetch gh-pages branch
60- run : git fetch origin gh-pages --depth=1
50+ - name : Deploy docs
51+ uses : ./.github/actions/python-mike-deploy
52+ with :
53+ version : ${{ steps.version.outputs.alias }}
54+ hidden : ' true'
6155
62- - name : Configure Git
63- run : |
64- git config --global user.name "github-actions[bot]"
65- git config --global user.email "github-actions[bot]@users.noreply.github.com"
56+ - name : Comment docs preview link on PR
57+ if : github.event_name == 'pull_request'
58+ uses : actions/github-script@v7
59+ with :
60+ script : |
61+ const marker = '<!-- mike-docs-preview -->';
62+ const alias = '${{ steps.version.outputs.alias }}';
63+ const version = '${{ steps.version.outputs.version }}';
64+ const url = `https://sift-stack.github.io/sift/python/${alias}/`;
65+ const body = [
66+ marker,
67+ `**Python docs preview:** ${url}`,
68+ ``,
69+ `Deployed from \`${version}\`. The link may take up to a minute to become live as GitHub Pages propagates.`,
70+ ].join('\n');
6671
67- - name : Deploy docs with mike
68- run : |
69- cd python
70- # Deploy dev/PR docs with hidden property to hide from version dropdown
71- mike deploy ${{ steps.version.outputs.alias }} --push --update-aliases --prop-set hidden=true
72- env :
73- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
72+ const { owner, repo } = context.repo;
73+ const issue_number = context.issue.number;
74+
75+ const { data: comments } = await github.rest.issues.listComments({
76+ owner, repo, issue_number, per_page: 100,
77+ });
78+ const existing = comments.find(c => c.body && c.body.includes(marker));
79+
80+ if (existing) {
81+ await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body });
82+ } else {
83+ await github.rest.issues.createComment({ owner, repo, issue_number, body });
84+ }
7485
7586 cleanup_docs :
7687 if : github.event.action == 'closed'
8394 with :
8495 fetch-depth : 1
8596
86- - name : Set up Python
87- uses : actions/setup-python@v4
88- with :
89- python-version : ' 3.11'
90-
91- - name : Install dependencies
92- run : |
93- cd python
94- pip install -e .[docs-build]
95-
96- - name : Fetch gh-pages branch
97- run : git fetch origin gh-pages --depth=1
98-
99- - name : Configure Git
100- run : |
101- git config --global user.name "github-actions[bot]"
102- git config --global user.email "github-actions[bot]@users.noreply.github.com"
103-
10497 - name : Delete PR docs
105- run : |
106- cd python
107- PR_ALIAS="pr-${{ github.event.number }}"
108- echo "Deleting docs for: $PR_ALIAS"
109-
110- # Check if the PR docs exist before trying to delete
111- if mike list | grep -q "$PR_ALIAS"; then
112- mike delete "$PR_ALIAS" --push
113- echo "Successfully deleted docs for $PR_ALIAS"
114- else
115- echo "No docs found for $PR_ALIAS, nothing to delete"
116- fi
117- env :
118- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
98+ uses : ./.github/actions/python-mike-delete
99+ with :
100+ version : pr-${{ github.event.number }}
0 commit comments