Skip to content

Commit d3040c8

Browse files
committed
Refactor deploy.yml for improved structure and clarity, including version injection and updated deployment messages
1 parent 5ad01e8 commit d3040c8

1 file changed

Lines changed: 36 additions & 18 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,75 @@
11
name: Deploy to GitHub Pages
22

3-
on:
4-
push:
5-
branches:
3+
on:
4+
push:
5+
branches:
66
- main
77
- dev
88
workflow_dispatch:
99

10-
permissions:
10+
permissions:
1111
contents: read
12-
pages: write
12+
pages: write
1313
id-token: write
1414

1515
concurrency:
16-
group: "pages"
16+
group: "pages"
1717
cancel-in-progress: true
1818

19-
jobs:
20-
build-and-deploy:
19+
jobs:
20+
build-and-deploy:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: Checkout main branch
2424
uses: actions/checkout@v4
25-
with:
25+
with:
2626
ref: main
2727
path: main-content
2828

29-
- name: Checkout dev branch
29+
- name: Checkout dev branch
3030
uses: actions/checkout@v4
31-
with:
31+
with:
3232
ref: dev
3333
path: dev-content
3434

35-
- name: Setup Pages
35+
- name: Get latest release version
36+
id: get_release
37+
run: |
38+
RELEASE_TAG=$(curl -s https://api.github.com/repos/MrAlders0n/MeshCore-GOME-WarDriver/releases/latest | jq -r '.tag_name')
39+
echo "version=$RELEASE_TAG" >> $GITHUB_OUTPUT
40+
41+
- name: Setup Pages
3642
uses: actions/configure-pages@v4
3743

38-
- name: Prepare combined deployment
44+
- name: Prepare combined deployment
45+
env:
46+
RELEASE_VERSION: ${{ steps.get_release. outputs.version }}
3947
run: |
4048
mkdir -p _site
4149
cp -r main-content/* _site/ 2>/dev/null || true
50+
51+
# Inject version into main branch
52+
sed -i 's|MeshCore Wardrive</h1>|MeshCore Wardrive <span class="text-sm text-slate-400">'"${RELEASE_VERSION}"'</span></h1>|' _site/index.html
53+
4254
mkdir -p _site/dev
4355
cp -r dev-content/* _site/dev/ 2>/dev/null || true
44-
rm -rf _site/. git _site/.github _site/dev/.git _site/dev/. github
56+
57+
# Inject dev badge with date
58+
DEV_DATE=$(date -u +"%Y-%m-%d %H:%M UTC")
59+
sed -i 's|MeshCore Wardrive</h1>|MeshCore Wardrive <span class="ml-2 px-2 py-0.5 text-xs font-semibold rounded bg-amber-600/20 text-amber-400 border border-amber-600/40">DEV</span> <span class="text-xs text-slate-500">'"${DEV_DATE}"'</span></h1>|' _site/dev/index.html
60+
61+
find _site -name ". git" -exec rm -rf {} + 2>/dev/null || true
62+
find _site -name ".github" -exec rm -rf {} + 2>/dev/null || true
4563
4664
- name: Upload artifact
4765
uses: actions/upload-pages-artifact@v3
4866

4967
- name: Deploy to GitHub Pages
5068
id: deployment
51-
uses: actions/deploy-pages@v4
52-
69+
uses: actions/deploy-pages@v4
70+
5371
- name: Comment deployment URL
5472
run: |
5573
echo "✅ Deployed successfully!"
56-
echo "📦 Main branch: https://mralders0n.github.io/MeshCore-GOME-WarDriver/"
57-
echo "🔧 Dev branch: https://mralders0n.github.io/MeshCore-GOME-WarDriver/dev/"
74+
echo "📦 Main branch (${{ steps.get_release.outputs.version }}): https://mralders0n.github.io/MeshCore-GOME-WarDriver/"
75+
echo "🔧 Dev branch: https://mralders0n.github.io/MeshCore-GOME-WarDriver/dev/"

0 commit comments

Comments
 (0)