|
| 1 | +# Workflow for publishing the students' website along with additional helpful information |
| 2 | + |
| 3 | +name: Deploy main branch as website |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + |
| 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 |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + pages: write |
| 16 | + id-token: write |
| 17 | + |
| 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. |
| 20 | +concurrency: |
| 21 | + group: "pages" |
| 22 | + cancel-in-progress: false |
| 23 | + |
| 24 | +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 | + shopt -s globstar |
| 101 | + for file in src/**/*.test.ts; do md5sum $file; done >> ./dist/integrity.html |
| 102 | + for file in src/**/*.test.tsx; do md5sum $file; done >> ./dist/integrity.html |
| 103 | + md5sum .eslintrc.js >> ./dist/integrity.html |
| 104 | + md5sum jest.config.js >> ./dist/integrity.html |
| 105 | + md5sum tsconfig.json >> ./dist/integrity.html |
| 106 | + md5sum .github/workflows/deploy.yml >> ./dist/integrity.html |
| 107 | + echo "</pre></body></html>" >> ./dist/integrity.html |
| 108 | + echo "* [Integrity](../integrity.html)" >> docs/quick-links.md |
| 109 | + # Create GitInspector Report |
| 110 | + - name: Create GitInspector Report |
| 111 | + if: ${{ !cancelled() }} |
| 112 | + id: gitinspector |
| 113 | + run: | |
| 114 | + git clone https://github.com/jpwhite3/gitinspector.git |
| 115 | + python ./gitinspector/gitinspector.py ./ --grading --format=html -f tsx,ts,html,css -x ./gitinspector -x ./node_modules -x ./wbcore > ./dist/git.html |
| 116 | + echo "* [Git Inspector](../git.html)" >> docs/quick-links.md |
| 117 | + # Generate HTML from Markdown in Docs/ |
| 118 | + - name: Generate HTML from Markdown in Docs/ |
| 119 | + if: ${{ !cancelled() }} |
| 120 | + id: markdown-docs |
| 121 | + uses: ldeluigi/markdown-docs@latest |
| 122 | + with: |
| 123 | + src: docs |
| 124 | + dst: dist/docs/ |
| 125 | + |
| 126 | + #- name: Handle Failure |
| 127 | + # run: | |
| 128 | + # echo "<html><body><h1>Build Failure</h1><p>The build failed during one of the steps.</p>" > ./dist/index.html |
| 129 | + #- uses: austenstone/[email protected] |
| 130 | + # id: job-summary |
| 131 | + # with: |
| 132 | + # create-pdf: false |
| 133 | + #- run: | |
| 134 | + # echo "${{ steps.job-summary.outputs.job-summary }}" >> ./dist/index.html |
| 135 | + # echo "</body></html>" >> ./dist/index.html |
| 136 | + # Deploy |
| 137 | + - name: Setup Pages |
| 138 | + uses: actions/configure-pages@v3 |
| 139 | + if: ${{ !cancelled() }} |
| 140 | + - name: Upload artifact |
| 141 | + uses: actions/upload-pages-artifact@v2 |
| 142 | + if: ${{ !cancelled() }} |
| 143 | + with: |
| 144 | + path: "dist/" |
| 145 | + - name: Deploy to GitHub Pages |
| 146 | + id: deployment |
| 147 | + uses: actions/deploy-pages@v2 |
| 148 | + if: ${{ !cancelled() }} |
0 commit comments