Skip to content

Commit b0c17bb

Browse files
authored
Create workflow.
1 parent 6c4be3b commit b0c17bb

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

.github/workflows/astro.yml

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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 site
6+
7+
on:
8+
# Runs on pushes targeting the default branch
9+
push:
10+
branches: ["main"]
11+
12+
# Allows you to run this workflow manually from the Actions tab
13+
workflow_dispatch:
14+
15+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
16+
permissions:
17+
contents: read
18+
pages: write
19+
id-token: write
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+
BUILD_PATH: "." # default value when not using subfolders
29+
# BUILD_PATH: subfolder
30+
31+
jobs:
32+
build:
33+
name: Build
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
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+
exit 0
46+
elif [ -f "${{ github.workspace }}/package.json" ]; then
47+
echo "manager=npm" >> $GITHUB_OUTPUT
48+
echo "command=ci" >> $GITHUB_OUTPUT
49+
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
50+
exit 0
51+
else
52+
echo "Unable to determine package manager"
53+
exit 1
54+
fi
55+
- name: Setup Node
56+
uses: actions/setup-node@v4
57+
with:
58+
node-version: "20"
59+
cache: ${{ steps.detect-package-manager.outputs.manager }}
60+
cache-dependency-path: ${{ env.BUILD_PATH }}/package-lock.json
61+
- name: Setup Pages
62+
id: pages
63+
uses: actions/configure-pages@v4
64+
- name: Install dependencies
65+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
66+
working-directory: ${{ env.BUILD_PATH }}
67+
- name: Build with Astro
68+
run: |
69+
${{ steps.detect-package-manager.outputs.runner }} astro build \
70+
--site "${{ steps.pages.outputs.origin }}" \
71+
--base "${{ steps.pages.outputs.base_path }}"
72+
working-directory: ${{ env.BUILD_PATH }}
73+
- name: Upload artifact
74+
uses: actions/upload-pages-artifact@v3
75+
with:
76+
path: ${{ env.BUILD_PATH }}/dist
77+
78+
deploy:
79+
environment:
80+
name: github-pages
81+
url: ${{ steps.deployment.outputs.page_url }}
82+
needs: build
83+
runs-on: ubuntu-latest
84+
name: Deploy
85+
steps:
86+
- name: Deploy to GitHub Pages
87+
id: deployment
88+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)