Skip to content

Commit 1d3260a

Browse files
committed
ci: enhance GitHub Actions workflow for GitHub Pages deployment with API enablement and improved permissions
1 parent 05e5cc3 commit 1d3260a

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,26 @@ jobs:
297297
contents: read
298298
pages: write
299299
id-token: write
300+
actions: write # Add this permission
300301
environment:
301302
name: github-pages
302303
url: ${{ steps.deployment.outputs.page_url }}
303304

304305
steps:
305306
- uses: actions/checkout@v4
306307

308+
- name: Enable GitHub Pages
309+
run: |
310+
# Enable via API
311+
curl -L \
312+
-X POST \
313+
-H "Accept: application/vnd.github+json" \
314+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
315+
-H "X-GitHub-Api-Version: 2022-11-28" \
316+
https://api.github.com/repos/${{ github.repository }}/pages \
317+
-d '{"source":{"branch":"gh-pages","path":"/"}}'
318+
continue-on-error: true # Continue even if already enabled
319+
307320
- name: Setup Python
308321
uses: actions/setup-python@v5
309322
with:
@@ -409,18 +422,9 @@ jobs:
409422
- name: Deploy to GitHub Pages
410423
id: deployment
411424
uses: actions/deploy-pages@v4
412-
413-
deploy:
414-
needs: build
415-
runs-on: ubuntu-latest
416-
permissions:
417-
pages: write
418-
id-token: write
419-
environment:
420-
name: github-pages
421-
url: ${{ steps.deployment.outputs.page_url }}
422-
423-
steps:
424-
- name: Deploy to GitHub Pages
425-
id: deployment
426-
uses: actions/deploy-pages@v4
425+
with:
426+
token: ${{ secrets.GITHUB_TOKEN }}
427+
artifact_name: github-pages
428+
preview: false
429+
error_count: 3 # Number of retries
430+
timeout: 600000 # 10 minutes timeout

0 commit comments

Comments
 (0)