diff --git a/.github/workflows/approve-merge.yml b/.github/workflows/approve-merge.yml index 08c541af..ce0fc47b 100644 --- a/.github/workflows/approve-merge.yml +++ b/.github/workflows/approve-merge.yml @@ -21,19 +21,17 @@ on: - synchronize - reopened branches: - - main # Only trigger for PRs targeting main - paths: # Optional but recommended: only trigger for changes in specific parts of the repo - - 'dist/**' + - main jobs: approve-and-merge: runs-on: ubuntu-latest - if: github.event.pull_request.user.login == 'googlemaps-bot[bot]' && github.event.pull_request.head.ref == 'dist-to-main-pr' + if: github.event.pull_request.user.login == 'googlemaps-bot[bot]' && github.event.pull_request.head.ref == 'temp-build-branch' # change here steps: - name: Checkout code uses: actions/checkout@v3 with: - ref: ${{ github.event.pull_request.head.sha }} # Checkout the PR's head commit + ref: ${{ github.event.pull_request.head.ref }} # Checkout the PR's head commit token: ${{ secrets.GH_MERGE_TOKEN }} - name: Approve PR diff --git a/.github/workflows/dist-pr.yml b/.github/workflows/dist-pr.yml index cde4fe2d..6a643dec 100644 --- a/.github/workflows/dist-pr.yml +++ b/.github/workflows/dist-pr.yml @@ -34,18 +34,23 @@ jobs: git config --global user.name 'googlemaps-bot' git config --global user.email 'googlemaps-bot@users.noreply.github.com' - - name: Create Branch for PR - run: | - git fetch origin main - git checkout -b dist-to-main-pr origin/dist - - name: Create Pull Request run: | gh pr create \ --base main \ - --head dist-to-main-pr \ + --head temp-build-branch \ --title "chore: automated output update (dist)" \ --body "This PR contains updated build output from the dist branch." \ --label "automated pr,dist-update" + env: + GH_TOKEN: ${{ secrets.GH_MERGE_TOKEN }} + + - name: Check for Existing PR and Close (Optional) + run: | + EXISTING_PR=$(gh pr list --base main --head temp-build-branch --state open --json number -q '.[].number') + if [[ -n "$EXISTING_PR" ]]; then + echo "Found existing open PR(s) for temp-build-branch: $EXISTING_PR" + gh pr close "$EXISTING_PR" + fi env: GH_TOKEN: ${{ secrets.GH_MERGE_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 60c97439..71d5e819 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,7 +31,7 @@ jobs: - name: Checkout main uses: actions/checkout@v3 with: - ref: main # Checkout *main* initially + ref: main token: ${{ secrets.GH_MERGE_TOKEN }} fetch-depth: 0 @@ -64,17 +64,11 @@ jobs: - name: Deploy to Firebase Hosting run: firebase deploy --only hosting - - name: Checkout dist branch - run: git checkout -B dist origin/dist || git checkout -b dist + - name: Create temporary branch + run: git checkout -b temp-build-branch - - name: Prepare dist folder + - name: Commit and Push Changes (to temp branch) run: | - rm -rf samples - mkdir -p dist - cp -r ./dist/* ./dist/ - - - name: Commit and Push Changes (to dist) - run: | - git add . + git add dist git commit -m "Update dist folder" - git push --force origin dist \ No newline at end of file + git push --force origin temp-build-branch \ No newline at end of file