Skip to content

Deploy Web

Deploy Web #9

Workflow file for this run

name: Deploy Web
on:
workflow_dispatch:
jobs:
deploy:
name: Build & Deploy to Web Branch
runs-on: ubuntu-latest
permissions:
contents: write # needed for peanut to push the branch
pull-requests: write # needed for gh pr create
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0 # Full history needed for peanut to push to branch
- name: Create .env file
run: echo "MAPBOX_TOKEN=${{ secrets.MAPBOX_TOKEN }}" > .env
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: "3.44.0"
cache: true
- name: Get dependencies
run: flutter pub get
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Activate flutter_peanut
run: dart pub global activate peanut
# peanut builds Flutter web and pushes the output to a staging branch.
# We target web-deploy/N (not web directly) so there is something to PR.
- name: Build web (with --wasm)
id: build_wasm
run: dart pub global run peanut -b web-deploy/${{ github.run_number }} --wasm
continue-on-error: true
- name: Build web (fallback without --wasm)
if: steps.build_wasm.outcome == 'failure'
run: dart pub global run peanut -b web-deploy/${{ github.run_number }}
- name: Clear .env file
run: echo -n > .env
- name: Authenticate gh CLI
run: echo "$GH_TOKEN" | gh auth login --with-token
- name: Open PR from staging branch to web
run: |
gh pr create \
--base web \
--head web-deploy/${{ github.run_number }} \
--title "chore: deploy web build #${{ github.run_number }}" \
--body "## 🚀 Web Deploy
Automated web build triggered by [@${{ github.actor }}](https://github.com/${{ github.actor }}) via the **Deploy Web** workflow.
| Detail | Value |
|--------|-------|
| Run | #${{ github.run_number }} |
| Triggered by | @${{ github.actor }} |
| Source branch | \`${{ github.ref_name }}\` |
| Build mode | WASM (with fallback to JS) |
> ⚠️ The \`.env\` file has been cleared in this build. Secrets are managed via GitHub Secrets." \
--label "web-deploy" \
--label "automated"