|
1 | | -# Sample workflow for building and deploying an Astro site to GitHub Pages |
2 | | -# |
3 | | -# To get started with Astro see: https://docs.astro.build/en/getting-started/ |
4 | | -# |
| 1 | +# Build and deploy Astro site to GitHub Pages |
5 | 2 | name: Deploy Astro site to Pages |
6 | 3 |
|
7 | 4 | on: |
8 | | - # Runs on pushes targeting the default branch |
9 | 5 | push: |
10 | 6 | branches: ["main"] |
11 | | - |
12 | | - # Allows you to run this workflow manually from the Actions tab |
13 | 7 | workflow_dispatch: |
14 | 8 |
|
15 | | -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
16 | 9 | permissions: |
17 | 10 | contents: read |
18 | 11 | pages: write |
19 | 12 | id-token: write |
20 | 13 |
|
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 | 14 | concurrency: |
24 | 15 | group: "pages" |
25 | 16 | cancel-in-progress: false |
26 | 17 |
|
27 | | -env: |
28 | | - BUILD_PATH: "." # default value when not using subfolders |
29 | | - # BUILD_PATH: subfolder |
30 | | - |
31 | 18 | jobs: |
32 | 19 | build: |
33 | 20 | name: Build |
34 | 21 | runs-on: ubuntu-latest |
35 | 22 | steps: |
36 | 23 | - name: Checkout |
37 | 24 | uses: actions/checkout@v4 |
38 | | - - name: Detect package manager |
39 | | - id: detect-package-manager |
40 | | - run: | |
41 | | - if [ -f "${{ github.workspace }}/yarn.lock" ]; then |
42 | | - echo "manager=yarn" >> $GITHUB_OUTPUT |
43 | | - echo "command=install" >> $GITHUB_OUTPUT |
44 | | - echo "runner=yarn" >> $GITHUB_OUTPUT |
45 | | - echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT |
46 | | - exit 0 |
47 | | - elif [ -f "${{ github.workspace }}/package.json" ]; then |
48 | | - echo "manager=npm" >> $GITHUB_OUTPUT |
49 | | - echo "command=install" >> $GITHUB_OUTPUT |
50 | | - echo "runner=npm" >> $GITHUB_OUTPUT |
51 | | - echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT |
52 | | - exit 0 |
53 | | - else |
54 | | - echo "Unable to determine package manager" |
55 | | - exit 1 |
56 | | - fi |
57 | | - - name: Setup Node |
58 | | - uses: actions/setup-node@v4 |
59 | | - with: |
60 | | - node-version: "20" |
61 | | - cache: ${{ steps.detect-package-manager.outputs.manager }} |
62 | | - ## cache-dependency-path: ${{ env.BUILD_PATH }}/${{ steps.detect-package-manager.outputs.lockfile }} |
| 25 | + |
| 26 | + - name: Setup Bun |
| 27 | + uses: oven-sh/setup-bun@v2 |
| 28 | + |
63 | 29 | - name: Setup Pages |
64 | 30 | id: pages |
65 | 31 | uses: actions/configure-pages@v5 |
| 32 | + |
66 | 33 | - name: Install dependencies |
67 | | - run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} |
68 | | - working-directory: ${{ env.BUILD_PATH }} |
| 34 | + run: bun install |
| 35 | + |
69 | 36 | - name: Build with Astro |
70 | | - run: | |
71 | | - ${{ steps.detect-package-manager.outputs.runner }} run build |
72 | | - working-directory: ${{ env.BUILD_PATH }} |
| 37 | + run: bun run build |
| 38 | + |
73 | 39 | - name: Upload artifact |
74 | 40 | uses: actions/upload-pages-artifact@v3 |
75 | 41 | with: |
76 | | - path: ${{ env.BUILD_PATH }}/dist |
| 42 | + path: dist |
77 | 43 |
|
78 | 44 | deploy: |
| 45 | + name: Deploy |
| 46 | + needs: build |
| 47 | + runs-on: ubuntu-latest |
79 | 48 | environment: |
80 | 49 | name: github-pages |
81 | 50 | url: ${{ steps.deployment.outputs.page_url }} |
82 | | - needs: build |
83 | | - runs-on: ubuntu-latest |
84 | | - name: Deploy |
85 | 51 | steps: |
86 | 52 | - name: Deploy to GitHub Pages |
87 | 53 | id: deployment |
|
0 commit comments