Skip to content

Commit 0b91db6

Browse files
committed
Refactor GitHub Actions workflow for improved deployment structure and clarity
1 parent bc54593 commit 0b91db6

1 file changed

Lines changed: 38 additions & 11 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,62 @@ on:
44
push:
55
branches:
66
- main
7+
- dev
78
workflow_dispatch:
89

9-
permissions:
10+
permissions:
1011
contents: read
11-
pages: write
12+
pages: write
1213
id-token: write
1314

1415
concurrency:
15-
group: "pages"
16-
cancel-in-progress: false
16+
group: "pages-${{ github.ref }}"
17+
cancel-in-progress: true
1718

1819
jobs:
19-
deploy:
20-
environment:
21-
name: github-pages
22-
url: ${{ steps.deployment.outputs.page_url }}
20+
build-and-deploy:
2321
runs-on: ubuntu-latest
2422
steps:
25-
- name: Checkout
23+
- name: Checkout
2624
uses: actions/checkout@v4
2725

26+
- name: Determine deployment path
27+
id: deploy-path
28+
run: |
29+
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
30+
echo "path=." >> $GITHUB_OUTPUT
31+
echo "environment=production" >> $GITHUB_OUTPUT
32+
else
33+
echo "path=dev" >> $GITHUB_OUTPUT
34+
echo "environment=development" >> $GITHUB_OUTPUT
35+
fi
36+
2837
- name: Setup Pages
2938
uses: actions/configure-pages@v4
3039

40+
- name: Prepare deployment directory
41+
run: |
42+
mkdir -p _site/${{ steps. deploy-path.outputs.path }}
43+
if [ "${{ steps. deploy-path.outputs.path }}" == "." ]; then
44+
cp -r * _site/ 2>/dev/null || true
45+
cp -r .??* _site/ 2>/dev/null || true
46+
rm -rf _site/.git _site/.github
47+
else
48+
cp -r * _site/${{ steps.deploy-path.outputs.path }}/ 2>/dev/null || true
49+
rm -rf _site/${{ steps.deploy-path.outputs.path }}/.git
50+
fi
51+
3152
- name: Upload artifact
3253
uses: actions/upload-pages-artifact@v3
33-
with:
34-
path: '.'
3554

3655
- name: Deploy to GitHub Pages
3756
id: deployment
3857
uses: actions/deploy-pages@v4
58+
59+
- name: Comment deployment URL
60+
run: |
61+
if [ "${{ steps.deploy-path.outputs.environment }}" == "production" ]; then
62+
echo "✅ Production deployed to main site"
63+
else
64+
echo "✅ Development deployed to /dev subdirectory"
65+
fi

0 commit comments

Comments
 (0)