|
2 | 2 | #
|
3 | 3 | # To get started with Astro see: https://docs.astro.build/en/getting-started/
|
4 | 4 | #
|
5 |
| -name: Deploy Astro site to Pages |
| 5 | +name: Deploy Developer-Icons to GitHub Pages |
6 | 6 |
|
7 | 7 | on:
|
8 |
| - # Trigger the workflow every time you push to the `main` branch |
| 8 | + # Runs on pushes targeting the default branch |
9 | 9 | push:
|
10 |
| - branches: [deploy, main] |
11 |
| - # Allows you to run this workflow manually from the Actions tab on GitHub. |
| 10 | + branches: ["main"] |
| 11 | + |
| 12 | + # Allows you to run this workflow manually from the Actions tab |
12 | 13 | workflow_dispatch:
|
13 | 14 |
|
14 |
| - # Allow this job to clone the repo and create a page deployment |
| 15 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
15 | 16 | permissions:
|
16 | 17 | contents: read
|
17 | 18 | pages: write
|
18 | 19 | id-token: write
|
19 | 20 |
|
| 21 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 22 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 23 | +concurrency: |
| 24 | + group: "pages" |
| 25 | + cancel-in-progress: false |
| 26 | + |
| 27 | +env: |
| 28 | + VITE_PUBLIC_BASE_URL: "/developer-icons" |
| 29 | + BUILD_PATH: "docs" # default value when not using subfolders |
| 30 | + # BUILD_PATH: subfolder |
| 31 | + |
20 | 32 | jobs:
|
21 | 33 | build:
|
| 34 | + name: Build |
22 | 35 | runs-on: ubuntu-latest
|
23 | 36 | steps:
|
24 |
| - - name: Check out your repository using git |
25 |
| - uses: actions/checkout@v2 |
26 |
| - |
27 |
| - - name: Use Node.js 20 |
28 |
| - uses: actions/setup-node@v2 |
| 37 | + - name: Checkout |
| 38 | + uses: actions/checkout@v4 |
| 39 | + - name: Detect package manager |
| 40 | + id: detect-package-manager |
| 41 | + run: | |
| 42 | + if [ -f "${{ github.workspace }}/yarn.lock" ]; then |
| 43 | + echo "manager=yarn" >> $GITHUB_OUTPUT |
| 44 | + echo "command=install" >> $GITHUB_OUTPUT |
| 45 | + echo "runner=yarn" >> $GITHUB_OUTPUT |
| 46 | + echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT |
| 47 | + exit 0 |
| 48 | + elif [ -f "${{ github.workspace }}/package.json" ]; then |
| 49 | + echo "manager=npm" >> $GITHUB_OUTPUT |
| 50 | + echo "command=ci" >> $GITHUB_OUTPUT |
| 51 | + echo "runner=npx --no-install" >> $GITHUB_OUTPUT |
| 52 | + echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT |
| 53 | + exit 0 |
| 54 | + else |
| 55 | + echo "Unable to determine package manager" |
| 56 | + exit 1 |
| 57 | + fi |
| 58 | + - name: Setup Node |
| 59 | + uses: actions/setup-node@v4 |
29 | 60 | with:
|
30 | 61 | node-version: "20"
|
31 |
| - cache: "npm" |
32 |
| - |
33 |
| - # Not using npm? Change `npm ci` to `yarn install` or `pnpm i` |
| 62 | + cache: ${{ steps.detect-package-manager.outputs.manager }} |
| 63 | + cache-dependency-path: ${{ env.BUILD_PATH }}/${{ steps.detect-package-manager.outputs.lockfile }} |
| 64 | + - name: Setup Pages |
| 65 | + id: pages |
| 66 | + uses: actions/configure-pages@v5 |
34 | 67 | - name: Install dependencies
|
35 |
| - run: cd docs && npm ci |
36 |
| - |
37 |
| - # Not using npm? Change `npm run build` to `yarn build` or `pnpm run build` |
38 |
| - - name: Build Astro |
39 |
| - run: npm run build:docs --if-present |
40 |
| - |
| 68 | + run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} |
| 69 | + working-directory: ${{ env.BUILD_PATH }} |
| 70 | + - name: Build with Astro |
| 71 | + run: | |
| 72 | + ${{ steps.detect-package-manager.outputs.runner }} astro build \ |
| 73 | + --site "${{ steps.pages.outputs.origin }}" \ |
| 74 | + --base "${{ steps.pages.outputs.base_path }}" |
| 75 | + working-directory: ${{ env.BUILD_PATH }} |
41 | 76 | - name: Upload artifact
|
42 |
| - uses: actions/upload-pages-artifact@v1 |
| 77 | + uses: actions/upload-pages-artifact@v3 |
43 | 78 | with:
|
44 |
| - path: ./docs/dist |
| 79 | + path: ${{ env.BUILD_PATH }}/dist |
45 | 80 |
|
46 | 81 | deploy:
|
47 | 82 | environment:
|
48 | 83 | name: github-pages
|
49 | 84 | url: ${{ steps.deployment.outputs.page_url }}
|
50 |
| - runs-on: ubuntu-latest |
51 | 85 | needs: build
|
| 86 | + runs-on: ubuntu-latest |
| 87 | + name: Deploy |
52 | 88 | steps:
|
53 | 89 | - name: Deploy to GitHub Pages
|
54 | 90 | id: deployment
|
55 |
| - uses: actions/deploy-pages@v1 |
| 91 | + uses: actions/deploy-pages@v4 |
0 commit comments