|
3 | 3 | name: Deploy main branch as website
|
4 | 4 |
|
5 | 5 | on:
|
6 |
| - push: |
7 |
| - branches: [main] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
8 | 9 |
|
9 |
| - # Allows you to run this workflow manually from the Actions tab |
10 |
| - workflow_dispatch: |
11 |
| - |
12 |
| -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 10 | +# Required permissions for Pages v4 + artifact v4 |
13 | 11 | permissions:
|
14 |
| - contents: read |
15 |
| - pages: write |
16 |
| - id-token: write |
| 12 | + actions: read # NEW: required by deploy-pages@v4 |
| 13 | + contents: read |
| 14 | + pages: write |
| 15 | + id-token: write |
17 | 16 |
|
18 |
| -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
19 |
| -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 17 | +# Only one concurrent deployment |
20 | 18 | concurrency:
|
21 |
| - group: "pages" |
22 |
| - cancel-in-progress: false |
| 19 | + group: "pages" |
| 20 | + cancel-in-progress: false |
23 | 21 |
|
24 | 22 | jobs:
|
25 |
| - deploy: |
26 |
| - runs-on: ubuntu-latest |
27 |
| - steps: |
28 |
| - - name: Checkout |
29 |
| - uses: actions/checkout@v4 |
30 |
| - with: |
31 |
| - fetch-depth: 0 |
32 |
| - - name: Use Node.js ${{ matrix.node-version }} |
33 |
| - uses: actions/setup-node@v3 |
34 |
| - with: |
35 |
| - node-version: ${{ matrix.node-version }} |
36 |
| - - id: get-repo-values |
37 |
| - name: Get repository values |
38 |
| - run: | |
39 |
| - url=https://$(echo "${{github.repository}}" | sed "s/\//.github.io\//") |
40 |
| - echo "url=$url" >> $GITHUB_OUTPUT |
41 |
| - - name: Update package.json homepage |
42 |
| - uses: jossef/action-set-json-field@v1 |
43 |
| - with: |
44 |
| - file: package.json |
45 |
| - field: homepage |
46 |
| - value: ${{ steps.get-repo-values.outputs.url }} |
47 |
| - # create_redirects |
48 |
| - - name: Create Redirects and Links |
49 |
| - id: create_redirects |
50 |
| - run: | |
51 |
| - mkdir -p dist |
52 |
| - echo "<html><head>\ |
53 |
| - <meta http-equiv='refresh' content='0; URL=${{github.server_url}}/${{github.repository}}' />\ |
54 |
| - </head><body>Redirecting to repository</body></html>" > ./dist/repo.html |
55 |
| -
|
56 |
| - mkdir -p docs |
57 |
| - cp README.md docs/index.md |
58 |
| - echo "# Quick Links" > docs/quick-links.md |
59 |
| - echo "* [Repository](../repo.html)" >> docs/quick-links.md |
60 |
| - echo "<html><head>\ |
61 |
| - <meta http-equiv='refresh' content='0; URL=docs/quick-links' />\ |
62 |
| - </head><body>Redirecting to quick links page</body></html>" > ./dist/quick.html |
63 |
| - # Install node packages |
64 |
| - - name: Install |
65 |
| - id: install |
66 |
| - run: | |
67 |
| - echo "<html><body><pre>" > ./dist/installation.html |
68 |
| - npm install |& tee -a ./dist/installation.html |
69 |
| - echo "</pre></body></html>" >> ./dist/installation.html |
70 |
| - echo "* [Installation](../installation.html)" >> docs/quick-links.md |
71 |
| - # Run linter |
72 |
| - - name: Run Linter |
73 |
| - id: lint |
74 |
| - run: | |
75 |
| - npm run eslint-output |
76 |
| - echo "* [Linter](../lint.html)" >> docs/quick-links.md |
77 |
| - # Build the project |
78 |
| - - name: Build the project |
79 |
| - id: build |
80 |
| - run: | |
81 |
| - echo "<html><body><pre>" > ./dist/build.html |
82 |
| - npm run build |& tee -a ./dist/build.html |
83 |
| - mv ./build/* ./dist |
84 |
| - echo "</pre></body></html>" >> ./dist/build.html |
85 |
| - echo "* [Build](../build.html)" >> docs/quick-links.md |
86 |
| - # Run Tests |
87 |
| - - name: Run Tests |
88 |
| - id: test |
89 |
| - run: | |
90 |
| - echo "<html><body><pre>" > ./dist/tests.html |
91 |
| - npm run test -- --coverage |& tee -a ./dist/tests.html |
92 |
| - echo "</pre></body></html>" >> ./dist/tests.html |
93 |
| - echo "* [Tests](../tests.html)" >> docs/quick-links.md |
94 |
| - # Verify Integrity |
95 |
| - - name: Verify Integrity |
96 |
| - if: ${{ !cancelled() }} |
97 |
| - id: integrity |
98 |
| - run: | |
99 |
| - echo "<html><body><pre>" > ./dist/integrity.html |
100 |
| - find src -type f -name "*.test.ts" -exec md5sum {} + >> ./dist/integrity.html |
101 |
| - find src -type f -name "*.test.tsx" -exec md5sum {} + >> ./dist/integrity.html |
102 |
| - md5sum .eslintrc.js >> ./dist/integrity.html |
103 |
| - md5sum jest.config.js >> ./dist/integrity.html |
104 |
| - md5sum tsconfig.json >> ./dist/integrity.html |
105 |
| - md5sum .github/workflows/deploy.yml >> ./dist/integrity.html |
106 |
| - echo "</pre></body></html>" >> ./dist/integrity.html |
107 |
| - echo "* [Integrity](../integrity.html)" >> docs/quick-links.md |
108 |
| - # Create GitInspector Report |
109 |
| - - name: Create GitInspector Report |
110 |
| - if: ${{ !cancelled() }} |
111 |
| - id: gitinspector |
112 |
| - run: | |
113 |
| - git clone https://github.com/jpwhite3/gitinspector.git |
114 |
| - python ./gitinspector/gitinspector.py ./ --grading --format=html -f tsx,ts,html,css -x ./gitinspector -x ./node_modules -x ./wbcore > ./dist/git.html |
115 |
| - echo "* [Git Inspector](../git.html)" >> docs/quick-links.md |
116 |
| - # Generate HTML from Markdown in Docs/ |
117 |
| - - name: Generate HTML from Markdown in Docs/ |
118 |
| - if: ${{ !cancelled() }} |
119 |
| - id: markdown-docs |
120 |
| - uses: ldeluigi/markdown-docs@latest |
121 |
| - with: |
122 |
| - src: docs |
123 |
| - dst: dist/docs/ |
124 |
| - |
125 |
| - #- name: Handle Failure |
126 |
| - # run: | |
127 |
| - # echo "<html><body><h1>Build Failure</h1><p>The build failed during one of the steps.</p>" > ./dist/index.html |
128 |
| - #- uses: austenstone/[email protected] |
129 |
| - # id: job-summary |
130 |
| - # with: |
131 |
| - # create-pdf: false |
132 |
| - #- run: | |
133 |
| - # echo "${{ steps.job-summary.outputs.job-summary }}" >> ./dist/index.html |
134 |
| - # echo "</body></html>" >> ./dist/index.html |
135 |
| - # Deploy |
136 |
| - - name: Setup Pages |
137 |
| - uses: actions/configure-pages@v3 |
138 |
| - if: ${{ !cancelled() }} |
139 |
| - - name: Upload artifact |
140 |
| - uses: actions/upload-pages-artifact@v3 |
141 |
| - if: ${{ !cancelled() }} |
142 |
| - with: |
143 |
| - path: "dist/" |
144 |
| - - name: Deploy to GitHub Pages |
145 |
| - id: deployment |
146 |
| - uses: actions/deploy-pages@v2 |
147 |
| - if: ${{ !cancelled() }} |
| 23 | + deploy: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + |
| 26 | + # Recommended for Pages so the URL shows on the run summary |
| 27 | + environment: |
| 28 | + name: github-pages |
| 29 | + url: ${{ steps.deployment.outputs.page_url }} |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + fetch-depth: 0 |
| 36 | + |
| 37 | + - name: Use Node.js 20 |
| 38 | + uses: actions/setup-node@v4 |
| 39 | + with: |
| 40 | + node-version: 20 |
| 41 | + cache: "npm" |
| 42 | + |
| 43 | + - id: get-repo-values |
| 44 | + name: Get repository values |
| 45 | + run: | |
| 46 | + url=https://$(echo "${{ github.repository }}" | sed "s/\//.github.io\//") |
| 47 | + echo "url=$url" >> $GITHUB_OUTPUT |
| 48 | +
|
| 49 | + - name: Update package.json homepage |
| 50 | + uses: jossef/action-set-json-field@v1 |
| 51 | + with: |
| 52 | + file: package.json |
| 53 | + field: homepage |
| 54 | + value: ${{ steps.get-repo-values.outputs.url }} |
| 55 | + |
| 56 | + # create_redirects |
| 57 | + - name: Create Redirects and Links |
| 58 | + id: create_redirects |
| 59 | + run: | |
| 60 | + mkdir -p dist |
| 61 | + echo "<html><head>\ |
| 62 | + <meta http-equiv='refresh' content='0; URL=${{github.server_url}}/${{github.repository}}' />\ |
| 63 | + </head><body>Redirecting to repository</body></html>" > ./dist/repo.html |
| 64 | + mkdir -p docs |
| 65 | + cp README.md docs/index.md |
| 66 | + echo "# Quick Links" > docs/quick-links.md |
| 67 | + echo "* [Repository](../repo.html)" >> docs/quick-links.md |
| 68 | + echo "<html><head>\ |
| 69 | + <meta http-equiv='refresh' content='0; URL=docs/quick-links' />\ |
| 70 | + </head><body>Redirecting to quick links page</body></html>" > ./dist/quick.html |
| 71 | +
|
| 72 | + # Install node packages |
| 73 | + - name: Install |
| 74 | + id: install |
| 75 | + run: | |
| 76 | + echo "<html><body><pre>" > ./dist/installation.html |
| 77 | + npm ci |& tee -a ./dist/installation.html |
| 78 | + echo "</pre></body></html>" >> ./dist/installation.html |
| 79 | + echo "* [Installation](../installation.html)" >> docs/quick-links.md |
| 80 | +
|
| 81 | + # Run linter (ensure your script writes dist/lint.html) |
| 82 | + - name: Run Linter |
| 83 | + id: lint |
| 84 | + run: | |
| 85 | + npm run eslint-output |
| 86 | + echo "* [Linter](../lint.html)" >> docs/quick-links.md |
| 87 | +
|
| 88 | + # Build the project |
| 89 | + - name: Build the project |
| 90 | + id: build |
| 91 | + run: | |
| 92 | + echo "<html><body><pre>" > ./dist/build.html |
| 93 | + npm run build |& tee -a ./dist/build.html |
| 94 | + mv ./build/* ./dist |
| 95 | + echo "</pre></body></html>" >> ./dist/build.html |
| 96 | + echo "* [Build](../build.html)" >> docs/quick-links.md |
| 97 | +
|
| 98 | + # Run Tests |
| 99 | + - name: Run Tests |
| 100 | + id: test |
| 101 | + run: | |
| 102 | + echo "<html><body><pre>" > ./dist/tests.html |
| 103 | + npm test -- --coverage |& tee -a ./dist/tests.html |
| 104 | + echo "</pre></body></html>" >> ./dist/tests.html |
| 105 | + echo "* [Tests](../tests.html)" >> docs/quick-links.md |
| 106 | +
|
| 107 | + # Verify Integrity |
| 108 | + - name: Verify Integrity |
| 109 | + if: ${{ !cancelled() }} |
| 110 | + id: integrity |
| 111 | + run: | |
| 112 | + echo "<html><body><pre>" > ./dist/integrity.html |
| 113 | + find src -type f -name "*.test.ts" -exec md5sum {} + >> ./dist/integrity.html |
| 114 | + find src -type f -name "*.test.tsx" -exec md5sum {} + >> ./dist/integrity.html |
| 115 | + md5sum .eslintrc.js >> ./dist/integrity.html |
| 116 | + md5sum jest.config.js >> ./dist/integrity.html |
| 117 | + md5sum tsconfig.json >> ./dist/integrity.html |
| 118 | + md5sum .github/workflows/deploy.yml >> ./dist/integrity.html |
| 119 | + echo "</pre></body></html>" >> ./dist/integrity.html |
| 120 | + echo "* [Integrity](../integrity.html)" >> docs/quick-links.md |
| 121 | +
|
| 122 | + # Create GitInspector Report |
| 123 | + - name: Create GitInspector Report |
| 124 | + if: ${{ !cancelled() }} |
| 125 | + id: gitinspector |
| 126 | + run: | |
| 127 | + git clone https://github.com/jpwhite3/gitinspector.git |
| 128 | + python ./gitinspector/gitinspector.py ./ --grading --format=html -f tsx,ts,html,css -x ./gitinspector -x ./node_modules -x ./wbcore > ./dist/git.html |
| 129 | + echo "* [Git Inspector](../git.html)" >> docs/quick-links.md |
| 130 | +
|
| 131 | + # Generate HTML from Markdown in Docs/ |
| 132 | + - name: Generate HTML from Markdown in Docs/ |
| 133 | + if: ${{ !cancelled() }} |
| 134 | + id: markdown-docs |
| 135 | + uses: ldeluigi/markdown-docs@latest |
| 136 | + with: |
| 137 | + src: docs |
| 138 | + dst: dist/docs/ |
| 139 | + |
| 140 | + # Pages |
| 141 | + - name: Setup Pages |
| 142 | + if: ${{ !cancelled() }} |
| 143 | + uses: actions/configure-pages@v5 |
| 144 | + |
| 145 | + - name: Upload artifact (for Pages) |
| 146 | + if: ${{ !cancelled() }} |
| 147 | + uses: actions/upload-pages-artifact@v4 |
| 148 | + with: |
| 149 | + path: "dist/" |
| 150 | + |
| 151 | + - name: Deploy to GitHub Pages |
| 152 | + if: ${{ !cancelled() }} |
| 153 | + id: deployment |
| 154 | + uses: actions/deploy-pages@v4 |
0 commit comments