Skip to content

Commit 0a94f16

Browse files
authored
feat: add workflow config to deploy app
Signed-off-by: Mukesh Kumar Chaudhary <[email protected]>
1 parent 6a95c87 commit 0a94f16

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

.github/workflows/astro.yml

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

0 commit comments

Comments
 (0)