From c8c6983e69c8c429b5d752c5f040f51828dd9ab3 Mon Sep 17 00:00:00 2001 From: Tam Nguyen Minh Date: Tue, 1 Aug 2023 12:48:38 +0700 Subject: [PATCH] [#255] Generate sample project as a part of test workflow --- .github/workflows/generate_sample.yml | 57 --------------------------- .github/workflows/test.yml | 56 +++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 62 deletions(-) delete mode 100644 .github/workflows/generate_sample.yml diff --git a/.github/workflows/generate_sample.yml b/.github/workflows/generate_sample.yml deleted file mode 100644 index 5a93ddce..00000000 --- a/.github/workflows/generate_sample.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Generate the sample project - -on: - push: - branches: - - develop - -jobs: - generate_sample_project: - # Run on merge commits only - if: ${{ contains(github.event.head_commit.message, 'Merge pull request') || (github.event.head_commit.author.email != 'bot@nimblehq.co') }} - name: Generate the sample project - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: Check out - uses: actions/checkout@v3 - with: - token: ${{ secrets.WIKI_ACTION_TOKEN }} - - - name: Set up Flutter environment - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - flutter-version: '3.10.5' - - - name: Remove the old sample project - run: | - rm -rf sample - - - name: Set the project name "sample" - uses: jossef/action-set-json-field@v2.1 - with: - file: mason-config.json - field: project_name - value: sample - - - name: Generate the new sample project - run: | - dart pub global activate mason_cli - mason get - mason make template -c mason-config.json - - - id: changes - name: Check for changes in the sample project - run: | - count=$(git status sample --porcelain | wc -l) - echo "count=$count" >> $GITHUB_OUTPUT - - - name: Commit & push the sample project changes - if: steps.changes.outputs.count > 0 - run: | - git config user.name team-nimblehq - git config user.email bot@nimblehq.co - git add sample - git commit -m "[Chore] Generate & update sample project" - git push diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1a6ebae8..1ae97f50 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,11 +4,6 @@ on: # but push action is only for the feature branch pull_request: types: [ opened, synchronize, reopened ] - push: - branches-ignore: - - develop - - 'release/**' - - main jobs: test: @@ -88,3 +83,54 @@ jobs: git add bricks git commit -m "[Chore] Generate Mason bundle" git push + + generate_sample_project: + # The job generate_sample_project identify that the job generate_mason_bundle must complete successfully + # before this generate_sample_project job will run + needs: generate_mason_bundle + name: Generate the sample project + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Check out + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + + - name: Set up Flutter environment + uses: subosito/flutter-action@v2 + with: + channel: 'stable' + flutter-version: '3.10.5' + + - name: Remove the old sample project + run: | + rm -rf sample + + - name: Set the project name "sample" + uses: jossef/action-set-json-field@v2.1 + with: + file: mason-config.json + field: project_name + value: sample + + - name: Generate the new sample project + run: | + dart pub global activate mason_cli + mason get + mason make template -c mason-config.json + + - id: changes + name: Check for changes in the sample project + run: | + count=$(git status sample --porcelain | wc -l) + echo "count=$count" >> $GITHUB_OUTPUT + + - name: Commit & push the sample project changes + if: steps.changes.outputs.count > 0 + run: | + git config user.name team-nimblehq + git config user.email bot@nimblehq.co + git add sample + git commit -m "[Chore] Generate & update sample project" + git push