update readme to include instructions for updating the website #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Workflow for building and deploying a preview of the Hugo site for a pull request | |
| name: Deploy Preview | |
| on: | |
| # Runs on pull requests targeting the main branch | |
| pull_request_target: | |
| branches: | |
| - main | |
| # Sets permissions of the GitHub TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Allow one concurrent deployment per pull request, and cancel in-progress runs. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| # Default to bash | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| # Build job | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| preview_url: ${{ steps.base_url.outputs.base_url }} | |
| env: | |
| HUGO_VERSION: 0.148.2 | |
| steps: | |
| - name: Install Hugo CLI | |
| run: | | |
| wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ | |
| && sudo dpkg -i ${{ runner.temp }}/hugo.deb | |
| - name: Install Dart Sass Embedded | |
| run: sudo snap install dart-sass-embedded | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup Pages | |
| id: pages | |
| uses: actions/configure-pages@v5 | |
| - name: Install Node.js dependencies | |
| run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" | |
| - name: Set preview baseURL | |
| id: base_url | |
| run: echo "base_url=https://yqtian.com/${{ github.event.repository.name }}/pr-${{ github.event.number }}" >> $GITHUB_OUTPUT | |
| - name: Build with Hugo | |
| env: | |
| # For maximum backward compatibility with Hugo modules | |
| HUGO_ENVIRONMENT: production | |
| HUGO_ENV: production | |
| run: | | |
| hugo \ | |
| --minify \ | |
| --baseURL "${{ steps.base_url.outputs.base_url }}/" \ | |
| --destination "public/pr-${{ github.event.number }}" | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./public | |
| # Deployment job | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ needs.build.outputs.preview_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| add-comment: | |
| runs-on: ubuntu-latest | |
| needs: [build, deploy] | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Add preview URL to PR | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body: | | |
| Preview deployed at: ${{ needs.build.outputs.preview_url }} |