From b9f77ba5e3c5d08518032e21ad0e7af03709d34a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 17 Oct 2023 16:22:31 +0200 Subject: [PATCH] Check account portal submodule --- .github/workflows/budibase_ci.yml | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 840d580892..976fe6fa11 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -290,3 +290,53 @@ jobs: } else { console.log('All good, the submodule had been merged and setup correctly!') } + + check-accountportal-submodule: + runs-on: ubuntu-latest + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'Budibase/budibase' + steps: + - name: Checkout repo and submodules + uses: actions/checkout@v3 + with: + submodules: true + token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} + fetch-depth: 0 + + - name: Check account portal commit + id: get_accountportal_commits + run: | + cd packages/account-portal + accountportal_commit=$(git rev-parse HEAD) + + branch="${{ github.base_ref || github.ref_name }}" + echo "Running on branch '$branch' (base_ref=${{ github.base_ref }}, ref_name=${{ github.head_ref }})" + + base_commit=$(git rev-parse origin/master) + + if [[ ! -z $base_commit ]]; then + echo "target_branch=$branch" + echo "target_branch=$branch" >> "$GITHUB_OUTPUT" + echo "accountportal_commit=$accountportal_commit" + echo "accountportal_commit=$accountportal_commit" >> "$GITHUB_OUTPUT" + echo "base_commit=$base_commit" + echo "base_commit=$base_commit" >> "$GITHUB_OUTPUT" + else + echo "Nothing to do - branch to branch merge." + fi + + - name: Check submodule merged to base branch + if: ${{ steps.get_accountportal_commits.outputs.base_commit != '' }} + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const submoduleCommit = '${{ steps.get_accountportal_commits.outputs.accountportal_commit }}'; + const baseCommit = '${{ steps.get_accountportal_commits.outputs.base_commit }}'; + + if (submoduleCommit !== baseCommit) { + console.error('Submodule commit does not match the latest commit on the "${{ steps.get_accountportal_commits.outputs.target_branch }}" branch.'); + console.error('Refer to the account portal repo to merge your changes: https://github.com/Budibase/account-portal/blob/master/docs/index.md') + process.exit(1); + } else { + console.log('All good, the submodule had been merged and setup correctly!') + }