|
1 | 1 | # When changes are pushed to the develop branch, |
2 | | -# build the current version of the User Guide |
3 | | -# with Sphinx and deploy it to the gh-pages branch. |
4 | | -# |
5 | | -# @todo Consolidate checkouts |
| 2 | +# build the develop and the next minor versions of the User Guide |
| 3 | +# with MkDocs and deploy them to GitHub Pages. |
6 | 4 | name: Deploy User Guide (latest) |
7 | 5 |
|
8 | 6 | on: |
9 | 7 | push: |
10 | 8 | branches: |
11 | 9 | - 'develop' |
12 | 10 | paths: |
13 | | - - 'user_guide_src/**' |
| 11 | + - 'docs/**' |
| 12 | + - 'mkdocs.yml' |
| 13 | + - 'admin/anchors.py' |
| 14 | + - 'admin/llms.py' |
| 15 | + - '.github/workflows/deploy-userguide-latest.yml' |
| 16 | + workflow_dispatch: |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: pages |
| 20 | + cancel-in-progress: false |
14 | 21 |
|
15 | 22 | permissions: |
16 | 23 | contents: read |
17 | 24 |
|
18 | 25 | jobs: |
19 | 26 | build: |
20 | | - name: Deploy to gh-pages |
21 | | - permissions: |
22 | | - # Allow push to branch gh-pages |
23 | | - contents: write |
| 27 | + name: Build User Guide |
24 | 28 | if: (github.repository == 'codeigniter4/CodeIgniter4') |
25 | 29 | runs-on: ubuntu-24.04 |
26 | 30 | steps: |
27 | | - - name: Checkout |
| 31 | + - name: Checkout develop |
28 | 32 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
29 | 33 | with: |
| 34 | + path: develop |
30 | 35 | persist-credentials: false |
31 | 36 |
|
32 | | - - name: Setup PHP |
33 | | - uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 |
| 37 | + - name: Checkout next minor |
| 38 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
34 | 39 | with: |
35 | | - php-version: '8.2' |
36 | | - coverage: none |
| 40 | + ref: '4.8' |
| 41 | + path: next |
| 42 | + persist-credentials: false |
37 | 43 |
|
38 | 44 | - name: Setup Python |
39 | 45 | uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 |
40 | 46 | with: |
41 | 47 | python-version: '3.12' |
42 | 48 |
|
43 | | - - name: Install Sphinx |
| 49 | + - name: Install MkDocs |
44 | 50 | run: | |
45 | 51 | python -m pip install --upgrade pip |
46 | | - pip install -r user_guide_src/requirements.txt |
| 52 | + pip install -r develop/docs/requirements.txt |
47 | 53 |
|
48 | | - # Build the latest User Guide |
49 | | - - name: Build Docs with Sphinx |
50 | | - run: make html |
51 | | - working-directory: user_guide_src |
| 54 | + - name: Setup Pages |
| 55 | + uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0 |
52 | 56 |
|
53 | | - - name: Add "Edit this page" links |
| 57 | + - name: Build the sites |
| 58 | + env: |
| 59 | + NO_MKDOCS_2_WARNING: '1' |
| 60 | + BASE_URL: https://codeigniter4.github.io/CodeIgniter4 |
54 | 61 | run: | |
55 | | - cd user_guide_src |
56 | | - # Fix permissions |
57 | | - sudo chown -R runner:docker build/html/ |
58 | | - php add-edit-this-page build/html/ |
| 62 | + mkdir pages |
| 63 | +
|
| 64 | + for name in develop next; do |
| 65 | + if [ ! -f "${name}/mkdocs.yml" ]; then |
| 66 | + echo "::notice::The ${name} branch has no mkdocs.yml, so it is not deployed." |
| 67 | + continue |
| 68 | + fi |
| 69 | +
|
| 70 | + ( |
| 71 | + cd "${name}" |
| 72 | + SITE_URL="${BASE_URL}/${name}/" mkdocs build --strict |
| 73 | + python admin/llms.py |
| 74 | + python admin/anchors.py |
| 75 | + ) |
| 76 | +
|
| 77 | + mv "${name}/site" "pages/${name}" |
| 78 | + done |
| 79 | +
|
| 80 | + cp develop/docs/overrides/assets/versions.json pages/versions.json |
| 81 | + echo '<!doctype html><meta http-equiv="refresh" content="0; url=develop/">' > pages/index.html |
59 | 82 |
|
60 | | - # Create an artifact of the html output |
61 | 83 | - name: Upload artifact |
62 | | - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 84 | + uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 |
63 | 85 | with: |
64 | | - name: HTML Documentation |
65 | | - path: user_guide_src/build/html/ |
66 | | - |
67 | | - # Commit changes to the gh-pages branch |
68 | | - - name: Commit changes |
69 | | - run: | |
70 | | - git clone https://github.com/codeigniter4/CodeIgniter4.git --branch gh-pages --single-branch gh-pages |
71 | | - cp -r user_guide_src/build/html/* gh-pages/ |
72 | | - cd gh-pages |
73 | | - git config --local user.email "action@github.com" |
74 | | - git config --local user.name "${GITHUB_ACTOR}" |
75 | | - git add . |
76 | | - # Ignore failures due to lack of changes |
77 | | - git commit -m "Update User Guide" -a || true |
| 86 | + path: pages |
78 | 87 |
|
79 | | - - name: Push changes |
80 | | - working-directory: gh-pages |
81 | | - env: |
82 | | - PUSH_TOKEN: ${{ secrets.ACCESS_TOKEN }} |
83 | | - run: bash ${GITHUB_WORKSPACE}/.github/scripts/secure-git-push https://github.com/codeigniter4/CodeIgniter4.git HEAD:gh-pages |
| 88 | + deploy: |
| 89 | + name: Deploy to GitHub Pages |
| 90 | + needs: build |
| 91 | + runs-on: ubuntu-24.04 |
| 92 | + permissions: |
| 93 | + pages: write |
| 94 | + id-token: write |
| 95 | + environment: |
| 96 | + name: github-pages |
| 97 | + url: ${{ steps.deployment.outputs.page_url }} |
| 98 | + steps: |
| 99 | + - name: Deploy |
| 100 | + id: deployment |
| 101 | + uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1 |
0 commit comments