Skip to content

Commit 1d7696a

Browse files
authored
Create astro.yml
Signed-off-by: Q1 Blue <105375894+q1blue@users.noreply.github.com>
1 parent 77d74cc commit 1d7696a

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

.github/workflows/astro.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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 one concurrent deployment
22+
concurrency:
23+
group: "pages"
24+
cancel-in-progress: true
25+
26+
env:
27+
BUILD_PATH: "." # default value when not using subfolders
28+
# BUILD_PATH: subfolder
29+
30+
jobs:
31+
build:
32+
name: Build
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v3
37+
- name: Detect package manager
38+
id: detect-package-manager
39+
run: |
40+
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
41+
echo "manager=yarn" >> $GITHUB_OUTPUT
42+
echo "command=install" >> $GITHUB_OUTPUT
43+
echo "runner=yarn" >> $GITHUB_OUTPUT
44+
exit 0
45+
elif [ -f "${{ github.workspace }}/package.json" ]; then
46+
echo "manager=npm" >> $GITHUB_OUTPUT
47+
echo "command=ci" >> $GITHUB_OUTPUT
48+
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
49+
exit 0
50+
else
51+
echo "Unable to determine packager manager"
52+
exit 1
53+
fi
54+
- name: Setup Node
55+
uses: actions/setup-node@v3
56+
with:
57+
node-version: "16"
58+
cache: ${{ steps.detect-package-manager.outputs.manager }}
59+
cache-dependency-path: ${{ env.BUILD_PATH }}/package-lock.json
60+
- name: Setup Pages
61+
id: pages
62+
uses: actions/configure-pages@v3
63+
- name: Install dependencies
64+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
65+
working-directory: ${{ env.BUILD_PATH }}
66+
- name: Build with Astro
67+
run: |
68+
${{ steps.detect-package-manager.outputs.runner }} astro build \
69+
--site "${{ steps.pages.outputs.origin }}" \
70+
--base "${{ steps.pages.outputs.base_path }}"
71+
working-directory: ${{ env.BUILD_PATH }}
72+
- name: Upload artifact
73+
uses: actions/upload-pages-artifact@v1
74+
with:
75+
path: ${{ env.BUILD_PATH }}/dist
76+
77+
deploy:
78+
environment:
79+
name: github-pages
80+
url: ${{ steps.deployment.outputs.page_url }}
81+
needs: build
82+
runs-on: ubuntu-latest
83+
name: Deploy
84+
steps:
85+
- name: Deploy to GitHub Pages
86+
id: deployment
87+
uses: actions/deploy-pages@v1

0 commit comments

Comments
 (0)