Enhance deployment workflow to include versioning and deployment date… #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: true | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout main branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| path: main-content | |
| - name: Checkout dev branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: dev | |
| path: dev-content | |
| - name: Get latest release version | |
| id: get_release | |
| run: | | |
| RELEASE_TAG=$(curl -s https://api.github.com/repos/MrAlders0n/MeshCore-GOME-WarDriver/releases/latest | jq -r '.tag_name') | |
| echo "version=$RELEASE_TAG" >> $GITHUB_OUTPUT | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Prepare combined deployment | |
| env: | |
| RELEASE_VERSION: ${{ steps.get_release.outputs.version }} | |
| DEPLOY_DATE: ${{ github.event.head_commit.timestamp }} | |
| run: | | |
| mkdir -p _site | |
| cp -r main-content/* _site/ 2>/dev/null || true | |
| # Inject version into main branch | |
| sed -i 's|<h1 class="flex items-center gap-2 text-xl font-semibold"><img class="h-8 w-8" src="content/wardrive.png" />|<h1 class="flex items-center gap-2 text-xl font-semibold"><img class="h-8 w-8" src="content/wardrive.png" />|' _site/index.html | |
| sed -i 's|MeshCore Wardrive</h1>|MeshCore Wardrive <span class="text-sm text-slate-400">'"${RELEASE_VERSION}"'</span></h1>|' _site/index.html | |
| mkdir -p _site/dev | |
| cp -r dev-content/* _site/dev/ 2>/dev/null || true | |
| # Inject dev version with date | |
| DEV_DATE=$(date -u +"%Y-%m-%d %H:%M UTC") | |
| sed -i 's|<h1 class="flex items-center gap-2 text-xl font-semibold"><img class="h-8 w-8" src="content/wardrive.png" />|<h1 class="flex items-center gap-2 text-xl font-semibold"><img class="h-8 w-8" src="content/wardrive.png" />|' _site/dev/index.html | |
| sed -i 's|MeshCore Wardrive</h1>|MeshCore Wardrive <span class="text-sm text-red-400">DEV</span><br><span class="text-xs text-slate-500">Deployed: '"${DEV_DATE}"'</span></h1>|' _site/dev/index.html | |
| find _site -name ". git" -exec rm -rf {} + 2>/dev/null || true | |
| find _site -name ".github" -exec rm -rf {} + 2>/dev/null || true | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| - name: Comment deployment URL | |
| run: | | |
| echo "✅ Deployed successfully!" | |
| echo "📦 Main branch (${{ steps.get_release.outputs.version }}): https://mralders0n.github.io/MeshCore-GOME-WarDriver/" | |
| echo "🔧 Dev branch: https://mralders0n.github.io/MeshCore-GOME-WarDriver/dev/" |