Skip to content

Commit 4541233

Browse files
authored
Create astro.yml
1 parent 6d50ebd commit 4541233

1 file changed

Lines changed: 93 additions & 0 deletions

File tree

.github/workflows/astro.yml

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

0 commit comments

Comments
 (0)