1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Error when building and deploying Flutter web app via GitHub Actions

Discussão em 'Mobile' iniciado por Stack, Outubro 2, 2024 às 11:34.

  1. Stack

    Stack Membro Participativo

    When trying to build and deploy Flutter web apps via GitHub Actions, the following error occurs:

    error: pathspec 'build/web/*' did not match any file(s) known to git


    Here is the YML code from .github/workflows:

    name: Deploy

    on:
    push:
    branches:
    - main

    jobs:
    build-and-deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
    uses: actions/checkout@v2

    - name: Set up Flutter
    uses: subosito/flutter-action@v2
    with:
    flutter-version: '3.24.3'

    - name: Install dependencies
    run: flutter pub get

    - name: Build Flutter web
    run: |
    echo "SUPABASE_URL=${{ secrets.SUPABASE_URL }}" >> .env
    echo "SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}" >> .env
    flutter build web

    - name: Deploy to production branch
    run: |
    git config --local user.email "my email"
    git config --local user.name "my name"

    if [ -d "build/web" ]; then
    echo "Build directory exists, proceeding with deployment."
    else
    echo "Build directory does not exist. Build might have failed."
    exit 1
    fi

    echo "Listing contents of build/web:"
    ls -la build/web

    git checkout -B production

    git rm -rf *

    git checkout main "build/web/*"

    echo "Listing contents of production branch after copying:"
    ls -la

    git add .
    git commit -m "Deploy to production"
    git push origin production
    env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    deploy-to-server:
    runs-on: ubuntu-latest
    needs: build-and-deploy
    steps:
    - uses: actions/checkout@v2

    - run: set -eu
    - run: mkdir "$HOME/.ssh"
    - run: echo "${{ secrets.SSH_KEY }}" > "$HOME/.ssh/key"
    - run: chmod 600 "$HOME/.ssh/key"

    - run: |
    rsync -e "ssh -p 20022 -i $HOME/.ssh/key -o StrictHostKeyChecking=no" \
    --archive --compress --delete \
    ./build/web/ HERE IS MY SITE



    In this code, when I change the main branch, I try to build the Flutter project, move the built files from build/web/ to the production branch and push the files to the server from there. But an error occurs. Does anyone know how to solve it?

    Continue reading...

Compartilhe esta Página