|
| 1 | +--- |
1 | 2 | name: Generate Docs |
2 | 3 |
|
3 | 4 | on: |
4 | | - push: |
5 | | - branches: |
6 | | - - main |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +permissions: {} |
7 | 10 |
|
8 | 11 | jobs: |
9 | | - docs: |
10 | | - name: Update Docs |
11 | | - runs-on: ubuntu-latest |
12 | | - steps: |
13 | | - - name: "Check out repository" |
14 | | - uses: actions/checkout@v4 |
15 | | - |
16 | | - - name: Print Rust version |
17 | | - run: rustc -vV |
18 | | - |
19 | | - - name: Generate Documentation |
20 | | - run: cargo doc --all-features --no-deps --document-private-items |
21 | | - |
22 | | - - name: Generate index file |
23 | | - shell: python3 {0} |
24 | | - run: | |
25 | | - import os |
26 | | -
|
27 | | - package = os.environ["PACKAGE_NAME"] |
28 | | - assert package |
29 | | -
|
30 | | - owner, sep, repository = os.environ["GITHUB_REPOSITORY"].partition("/") |
31 | | - assert owner |
32 | | - assert repository |
33 | | -
|
34 | | - doc = f"""<!DOCTYPE html> |
35 | | - <html> |
36 | | - <head> |
37 | | - <title>Redirecting to https://{owner}.github.io/{repository}/{package}/</title> |
38 | | - <meta charset="utf-8"> |
39 | | - <meta http-equiv="refresh" content="0; URL=https://{owner}.github.io/{repository}/{package}/"> |
40 | | - <link rel="canonical" href="https://{owner}.github.io/{repository}/{package}/"> |
41 | | - </head> |
42 | | - </html>""" |
43 | | -
|
44 | | - output_dir = os.environ["OUTPUT_DIR"] |
45 | | - assert output_dir |
46 | | - output_dir = os.path.join(output_dir, "index.html") |
47 | | -
|
48 | | - print(f"Writing to {output_dir}") |
49 | | - with open(output_dir, mode="w") as f: |
50 | | - f.write(doc) |
51 | | - env: |
52 | | - PACKAGE_NAME: vinylla |
53 | | - OUTPUT_DIR: target/doc |
54 | | - |
55 | | - - name: Deploy to GitHub Pages |
56 | | - uses: peaceiris/actions-gh-pages@v4 |
57 | | - with: |
58 | | - github_token: ${{ secrets.GITHUB_TOKEN }} |
59 | | - publish_dir: target/doc |
| 12 | + docs: |
| 13 | + name: Update Docs |
| 14 | + runs-on: ubuntu-latest |
| 15 | + permissions: |
| 16 | + contents: write # needed because peaceiris/actions-gh-pages writes to the gh-pages branch |
| 17 | + pages: write |
| 18 | + steps: |
| 19 | + - name: Check out repository |
| 20 | + uses: actions/checkout@v5 |
| 21 | + with: |
| 22 | + persist-credentials: false |
| 23 | + |
| 24 | + - name: Print Rust version |
| 25 | + run: rustc -vV |
| 26 | + |
| 27 | + - name: Generate Documentation |
| 28 | + run: cargo doc --all-features --no-deps --document-private-items |
| 29 | + |
| 30 | + - name: Generate index file |
| 31 | + shell: python3 {0} |
| 32 | + run: | |
| 33 | + import os |
| 34 | +
|
| 35 | + package = os.environ["PACKAGE_NAME"] |
| 36 | + assert package |
| 37 | +
|
| 38 | + owner, sep, repository = os.environ["GITHUB_REPOSITORY"].partition("/") |
| 39 | + assert owner |
| 40 | + assert repository |
| 41 | +
|
| 42 | + doc = f"""<!DOCTYPE html> |
| 43 | + <html> |
| 44 | + <head> |
| 45 | + <title>Redirecting to https://{owner}.github.io/{repository}/{package}/</title> |
| 46 | + <meta charset="utf-8"> |
| 47 | + <meta http-equiv="refresh" content="0; URL=https://{owner}.github.io/{repository}/{package}/"> |
| 48 | + <link rel="canonical" href="https://{owner}.github.io/{repository}/{package}/"> |
| 49 | + </head> |
| 50 | + </html>""" |
| 51 | +
|
| 52 | + output_dir = os.environ["OUTPUT_DIR"] |
| 53 | + assert output_dir |
| 54 | + output_dir = os.path.join(output_dir, "index.html") |
| 55 | +
|
| 56 | + print(f"Writing to {output_dir}") |
| 57 | + with open(output_dir, mode="w") as f: |
| 58 | + f.write(doc) |
| 59 | + env: |
| 60 | + PACKAGE_NAME: vinylla |
| 61 | + OUTPUT_DIR: target/doc |
| 62 | + |
| 63 | + - name: Deploy to GitHub Pages |
| 64 | + uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e |
| 65 | + with: |
| 66 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + publish_dir: target/doc |
0 commit comments