Skip to content

Commit 989a864

Browse files
authored
Create astro.yml
1 parent 70625ce commit 989a864

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

.github/workflows/astro.yml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
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+
with:
39+
submodules: true
40+
- name: Detect package manager
41+
id: detect-package-manager
42+
run: |
43+
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
44+
echo "manager=yarn" >> $GITHUB_OUTPUT
45+
echo "command=install" >> $GITHUB_OUTPUT
46+
echo "runner=yarn" >> $GITHUB_OUTPUT
47+
echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT
48+
exit 0
49+
elif [ -f "${{ github.workspace }}/package.json" ]; then
50+
echo "manager=npm" >> $GITHUB_OUTPUT
51+
echo "command=ci" >> $GITHUB_OUTPUT
52+
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
53+
echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT
54+
exit 0
55+
else
56+
echo "Unable to determine package manager"
57+
exit 1
58+
fi
59+
- name: Setup Node
60+
uses: actions/setup-node@v4
61+
with:
62+
node-version: "20"
63+
cache: ${{ steps.detect-package-manager.outputs.manager }}
64+
cache-dependency-path: ${{ env.BUILD_PATH }}/${{ steps.detect-package-manager.outputs.lockfile }}
65+
# Run transform on markdown files contained by submodules
66+
# - name: Transform Markdown
67+
# run: |
68+
# node ${{ github.workspace }}/.scripts/transform.js
69+
- name: Setup Pages
70+
id: pages
71+
uses: actions/configure-pages@v5
72+
- name: Install dependencies
73+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
74+
working-directory: ${{ env.BUILD_PATH }}
75+
- name: Build with Astro
76+
run: |
77+
${{ steps.detect-package-manager.outputs.runner }} astro build \
78+
--site "${{ steps.pages.outputs.origin }}" \
79+
--base "${{ steps.pages.outputs.base_path }}"
80+
working-directory: ${{ env.BUILD_PATH }}
81+
- name: Upload artifact
82+
uses: actions/upload-pages-artifact@v3
83+
with:
84+
path: ${{ env.BUILD_PATH }}/dist
85+
86+
deploy:
87+
environment:
88+
name: github-pages
89+
url: ${{ steps.deployment.outputs.page_url }}
90+
needs: build
91+
runs-on: ubuntu-latest
92+
name: Deploy
93+
steps:
94+
- name: Deploy to GitHub Pages
95+
id: deployment
96+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)