From 6be02d29ca0320e28fa00dc4b3b054eef94f386b Mon Sep 17 00:00:00 2001 From: Suesi Tran <17781268+suesitran@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:34:12 +1100 Subject: [PATCH 1/2] Merge and deploy script (#19) * first draft of merge and deploy script * Change to use pull_request trigger * Add firebase.json * Change to use self-hosted * do not need to install Firebase CLI --- .github/workflows/merge_and_deploy.yml | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/merge_and_deploy.yml diff --git a/.github/workflows/merge_and_deploy.yml b/.github/workflows/merge_and_deploy.yml new file mode 100644 index 0000000..b85b5af --- /dev/null +++ b/.github/workflows/merge_and_deploy.yml @@ -0,0 +1,45 @@ +# This is a basic workflow to help you get started with Actions + +name: Deploy to web after merge + +# Controls when the workflow will run +on: + # push: # trigger at each merge to main + pull_request: + branches: + - main + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + validate-and-build-apps: + name: 'Validate and build web app' + runs-on: self-hosted + concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + steps: + - name: checkout source code + uses: actions/checkout@v4.1.7 + with: + ref: ${{github.event.pull_request_target.head.ref}} + repository: ${{github.event.pull_request_target.head.repo.full_name}} + fetch-depth: 0 + - name: setup secrets + run: | + echo "$FIREBASE_OPTION" > lib/firebase_options.dart + env: + FIREBASE_OPTION: ${{ secrets.FIREBASE_OPTIONS }} + - name: Install Flutter + uses: subosito/flutter-action@v2.6.2 + with: + flutter-version: '3.22.0' + channel: 'stable' + # run firebase deploy --only hosting to deploy when development is done + - name: build and deploy web app + run: | + echo "$FIREBASE_JSON" > firebase.json + flutter pub get + flutter build web + firebase hosting:channel:deploy testing + env: + FIREBASE_JSON: ${{ secrets.FIREBASE_JSON }} From 8ac9c7d6ee33c7ea7877eec113889f7ccd227efd Mon Sep 17 00:00:00 2001 From: suesitran Date: Tue, 12 Nov 2024 16:31:36 +0700 Subject: [PATCH 2/2] always trigger when push to main --- .github/workflows/merge_and_deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/merge_and_deploy.yml b/.github/workflows/merge_and_deploy.yml index b85b5af..f956581 100644 --- a/.github/workflows/merge_and_deploy.yml +++ b/.github/workflows/merge_and_deploy.yml @@ -4,8 +4,7 @@ name: Deploy to web after merge # Controls when the workflow will run on: - # push: # trigger at each merge to main - pull_request: + push: # trigger at each merge to main branches: - main