Skip to content

Deploy to GitHub Pages #54

Deploy to GitHub Pages

Deploy to GitHub Pages #54

Workflow file for this run

name: Deploy to GitHub Pages
on:
workflow_run:
workflows: ["CI"]
types: [completed]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
build:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main') }}
runs-on: ubuntu-latest
steps:
- name: Checkout workflow_run commit
if: ${{ github.event_name == 'workflow_run' }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_sha }}
- name: Checkout manual dispatch ref
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
# flutter-version: '3.40.0' # 可選:指定版本
- name: Install dependencies
run: flutter pub get
- name: Write payment config
run: |
mkdir -p env
if [ -n "${{ secrets.PAYMENT_DEV_JSON }}" ]; then
cat > env/payment.dev.json << 'EOF'
${{ secrets.PAYMENT_DEV_JSON }}
EOF
else
echo "{}" > env/payment.dev.json
fi
- name: Build Web
run: flutter build web --release --base-href "/warmmemo/" --dart-define-from-file=env/payment.dev.json
- name: Add SPA fallback for GitHub Pages
run: |
cp build/web/index.html build/web/404.html
touch build/web/.nojekyll
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: build/web
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4