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- #
5- name : Deploy Astro site to Pages
1+ name : Deploy to GitHub Pages
62
73on :
8- # Runs on pushes targeting the default branch
4+ # Trigger the workflow every time you push to the `main` branch
5+ # Using a different branch name? Replace `main` with your branch’s name
96 push :
10- branches : ["master"]
11-
12- # Allows you to run this workflow manually from the Actions tab
7+ branches : [ master ]
8+ # Allows you to run this workflow manually from the Actions tab on GitHub.
139 workflow_dispatch :
1410
15- # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
11+ # Allow this job to clone the repo and create a page deployment
1612permissions :
1713 contents : read
1814 pages : write
1915 id-token : write
2016
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- BUILD_PATH : " ." # default value when not using subfolders
29- # BUILD_PATH: subfolder
30-
3117jobs :
3218 build :
33- name : Build
3419 runs-on : ubuntu-latest
3520 steps :
36- - name : Checkout
21+ - name : Checkout your repository using git
3722 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=ci" >> $GITHUB_OUTPUT
50- echo "runner=npx --no-install" >> $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 : " 22"
61- cache : ${{ steps.detect-package-manager.outputs.manager }}
62- # Include BUILD_PATH to ensure the correct full path to the lockfile
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
67- - name : Install dependencies
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 }}
76- - name : Upload artifact
77- uses : actions/upload-pages-artifact@v3
23+ - name : Install, build, and upload your site
24+ uses : withastro/action@v3
7825 with :
79- path : ${{ env.BUILD_PATH }}/dist
26+ path : . # The root location of your Astro project inside the repository. (optional)
27+ node-version : 22 # The specific version of Node that should be used to build your site. Defaults to 22. (optional)
28+ package-manager : pnpm@latest # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)
8029
8130 deploy :
31+ needs : build
32+ runs-on : ubuntu-latest
8233 environment :
8334 name : github-pages
8435 url : ${{ steps.deployment.outputs.page_url }}
85- needs : build
86- runs-on : ubuntu-latest
87- name : Deploy
8836 steps :
8937 - name : Deploy to GitHub Pages
9038 id : deployment
91- uses : actions/deploy-pages@v4
39+ uses : actions/deploy-pages@v4
0 commit comments