|
1 | | -# Sample workflow for building and deploying a Dartdoc site to GitHub Pages |
2 | 1 | name: Deploy Dartdoc with GitHub Pages dependencies preinstalled |
3 | 2 |
|
4 | 3 | on: |
5 | | - # Runs on pushes targeting the default branch |
6 | 4 | push: |
7 | 5 | branches: |
8 | | - - main |
9 | | - - develop |
10 | | - - 13-distribute-demo-app-for-validation |
| 6 | + - main |
| 7 | + - develop |
| 8 | + - 13-distribute-demo-app-for-validation |
| 9 | + |
11 | 10 |
|
12 | | - # Allows you to run this workflow manually from the Actions tab |
13 | 11 | workflow_dispatch: |
14 | 12 |
|
15 | | -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
16 | 13 | permissions: |
17 | | - contents: read |
| 14 | + contents: write |
18 | 15 | pages: write |
19 | 16 | id-token: write |
20 | 17 |
|
21 | | -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
22 | | -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
23 | 18 | concurrency: |
24 | 19 | group: "pages" |
25 | 20 | cancel-in-progress: false |
26 | 21 |
|
27 | 22 | jobs: |
28 | | - # Build job |
29 | 23 | build: |
30 | 24 | runs-on: ubuntu-latest |
31 | 25 | steps: |
@@ -58,19 +52,39 @@ jobs: |
58 | 52 | uses: actions/upload-pages-artifact@v3 |
59 | 53 | with: |
60 | 54 | path: ./docs |
61 | | - name: github-pages |
62 | 55 |
|
63 | | - # Deployment job |
64 | 56 | deploy: |
65 | | - environment: |
66 | | - name: github-pages |
67 | | - url: ${{ steps.deployment.outputs.page_url }} |
68 | 57 | runs-on: ubuntu-latest |
69 | 58 | needs: build |
70 | 59 | steps: |
71 | | - - name: Deploy to GitHub Pages |
72 | | - id: deployment |
73 | | - uses: actions/deploy-pages@v3 |
| 60 | + - name: Checkout repository |
| 61 | + uses: actions/checkout@v2 |
| 62 | + |
| 63 | + - name: Download artifact |
| 64 | + uses: actions/download-artifact@v4 |
74 | 65 | with: |
75 | | - token: ${{ secrets.GITHUB_TOKEN }} |
76 | | - artifact_name: github-pages |
| 66 | + name: github-pages |
| 67 | + |
| 68 | + - name: List files in current directory (to verify artifact) |
| 69 | + run: | |
| 70 | + ls -la |
| 71 | +
|
| 72 | + - name: Create docs directory if not exists |
| 73 | + run: | |
| 74 | + mkdir -p ./docs # S'assure que le dossier docs existe |
| 75 | +
|
| 76 | + - name: List files in docs folder |
| 77 | + run: ls -la ./docs # Vérifier que les fichiers sont bien extraits |
| 78 | + |
| 79 | + - name: Commit changes and push to gh-pages |
| 80 | + run: | |
| 81 | + git config --global user.name "GitHub Actions" |
| 82 | + git config --global user.email "actions@github.com" |
| 83 | + git checkout gh-pages || git checkout -b gh-pages |
| 84 | + find . -type f ! -name 'CNAME' -exec git rm -f {} + |
| 85 | + git add ./docs/* |
| 86 | + git commit -m "doc: deploy site to GitHub Pages" || echo "No changes to commit" |
| 87 | + git push origin gh-pages --force |
| 88 | + env: |
| 89 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 90 | + |
0 commit comments