|
| 1 | +name: Deploy GOV.UK Vue docs to GitHub Pages |
| 2 | + |
| 3 | +on: |
| 4 | + # Runs on pushes targeting the default branch |
| 5 | + push: |
| 6 | + branches: ["main"] |
| 7 | + |
| 8 | + # Run this workflow manually from the Actions tab |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + pages: write |
| 15 | + id-token: write |
| 16 | + |
| 17 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 18 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 19 | +concurrency: |
| 20 | + group: "pages" |
| 21 | + cancel-in-progress: false |
| 22 | + |
| 23 | +jobs: |
| 24 | + # Build job |
| 25 | + build: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v3 |
| 30 | + with: |
| 31 | + repository: 'govuk-vue/govuk-vue-docs' |
| 32 | + - name: Detect package manager |
| 33 | + id: detect-package-manager |
| 34 | + run: | |
| 35 | + if [ -f "${{ github.workspace }}/yarn.lock" ]; then |
| 36 | + echo "manager=yarn" >> $GITHUB_OUTPUT |
| 37 | + echo "command=install" >> $GITHUB_OUTPUT |
| 38 | + exit 0 |
| 39 | + elif [ -f "${{ github.workspace }}/package.json" ]; then |
| 40 | + echo "manager=npm" >> $GITHUB_OUTPUT |
| 41 | + echo "command=ci" >> $GITHUB_OUTPUT |
| 42 | + exit 0 |
| 43 | + else |
| 44 | + echo "Unable to determine package manager" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | + - name: Setup Node |
| 48 | + uses: actions/setup-node@v3 |
| 49 | + with: |
| 50 | + node-version: "18" |
| 51 | + cache: ${{ steps.detect-package-manager.outputs.manager }} |
| 52 | + - name: Setup Pages |
| 53 | + uses: actions/configure-pages@v3 |
| 54 | + - name: Restore cache |
| 55 | + uses: actions/cache@v3 |
| 56 | + with: |
| 57 | + path: | |
| 58 | + dist |
| 59 | + .nuxt |
| 60 | + key: ${{ runner.os }}-nuxt-build-${{ hashFiles('dist') }} |
| 61 | + restore-keys: | |
| 62 | + ${{ runner.os }}-nuxt-build- |
| 63 | + - name: Install dependencies |
| 64 | + run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} |
| 65 | + - name: Static HTML export with Nuxt |
| 66 | + run: ${{ steps.detect-package-manager.outputs.manager }} run generate |
| 67 | + - name: Upload artifact |
| 68 | + uses: actions/upload-pages-artifact@v2 |
| 69 | + with: |
| 70 | + path: ./dist |
| 71 | + |
| 72 | + # Deployment job |
| 73 | + deploy: |
| 74 | + environment: |
| 75 | + name: github-pages |
| 76 | + url: ${{ steps.deployment.outputs.page_url }} |
| 77 | + runs-on: ubuntu-latest |
| 78 | + needs: build |
| 79 | + steps: |
| 80 | + - name: Deploy to GitHub Pages |
| 81 | + id: deployment |
| 82 | + uses: actions/deploy-pages@v2 |
0 commit comments