From 0ae2610d38febe8f95b54d4c764f2c8d015cd489 Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Fri, 6 Sep 2024 11:31:34 +0200 Subject: [PATCH 1/2] fix: merge workflows into one, add git env variables for semantic release --- .../workflows/auto-merge-dependabot-nx-pr.yml | 59 +++++++++++++++++++ .../workflows/auto-merge-dependabot-pr.yml | 15 ----- .../workflows/auto-rebase-and-merge-nx-pr.yml | 24 -------- .github/workflows/release.yml | 2 + 4 files changed, 61 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/auto-merge-dependabot-nx-pr.yml delete mode 100644 .github/workflows/auto-merge-dependabot-pr.yml delete mode 100644 .github/workflows/auto-rebase-and-merge-nx-pr.yml diff --git a/.github/workflows/auto-merge-dependabot-nx-pr.yml b/.github/workflows/auto-merge-dependabot-nx-pr.yml new file mode 100644 index 00000000..6fc4c9d8 --- /dev/null +++ b/.github/workflows/auto-merge-dependabot-nx-pr.yml @@ -0,0 +1,59 @@ +name: Auto merge dependabot and NX PRs +on: + pull_request_target: +jobs: + auto-merge-dependabot-pr: + if: >- + github.event.pull_request.user.login == 'dependabot[bot]' && + ( + startsWith(github.head_ref, 'dependabot/npm_and_yarn/angular-') || + startsWith(github.head_ref, 'dependabot/npm_and_yarn/onecx-') || + startsWith(github.event.pull_request.title, 'chore(deps-dev)') + ) + runs-on: ubuntu-latest + steps: + - name: Auto Approve + uses: actions/github-script@v4 + with: + script: | + const result = await github.pulls.createReview({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number, + event: "APPROVE" + }) + - name: Enable auto-merge for Dependabot PRs + run: gh pr merge --auto --squash "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + rebase-merge-nx-pr: + name: Rebase and merge + runs-on: ubuntu-latest + if: github.event.pull_request.user.login == 'tkit-dev' && startsWith(github.head_ref, 'migrate-nx-to-') + steps: + - name: Checkout the latest code + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 # otherwise, you will fail to push refs to dest repo + - name: Automatic Rebase + uses: cirrus-actions/rebase@1.8 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Auto Approve + uses: actions/github-script@v4 + with: + script: | + const result = await github.pulls.createReview({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number, + event: "APPROVE" + }) + - name: Enable auto-merge for NX PRs + run: gh pr merge --auto --squash "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file diff --git a/.github/workflows/auto-merge-dependabot-pr.yml b/.github/workflows/auto-merge-dependabot-pr.yml deleted file mode 100644 index 2a797813..00000000 --- a/.github/workflows/auto-merge-dependabot-pr.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Auto merge dependabot Angular PRs -on: - pull_request_target: - types: [opened] -jobs: - auto-merge: - if: github.event.pull_request.user.login == 'dependabot' && startsWith(github.head_ref, 'dependabot/npm_and_yarn/angular-') - runs-on: ubuntu-latest - steps: - - name: Enable auto-merge for Dependabot PRs - if: ${{ contains(github.event.pull_request.title, 'bump')}} - run: gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/auto-rebase-and-merge-nx-pr.yml b/.github/workflows/auto-rebase-and-merge-nx-pr.yml deleted file mode 100644 index 5877c1ea..00000000 --- a/.github/workflows/auto-rebase-and-merge-nx-pr.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Automatic rebase and merge NX PRs -on: - pull_request_target: - types: [opened] -jobs: - rebase: - name: Rebase and merge - runs-on: ubuntu-latest - if: github.event.pull_request.user.login == 'tkit-dev' && startsWith(github.head_ref, 'migrate-nx-to-') - steps: - - name: Checkout the latest code - uses: actions/checkout@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - fetch-depth: 0 # otherwise, you will fail to push refs to dest repo - - name: Automatic Rebase - uses: cirrus-actions/rebase@1.8 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Enable auto-merge for NX PRs - run: gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 70605b1c..bef34087 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,3 +22,5 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GIT_AUTHOR_NAME: tkit-dev + GIT_AUTHOR_EMAIL: tkit-dev@1000kit.org From 21834906bd37fe37f91efbc538ae6ada4226cd99 Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Fri, 6 Sep 2024 11:41:10 +0200 Subject: [PATCH 2/2] fix: revert merging workflows --- .../workflows/auto-merge-dependabot-nx-pr.yml | 59 ------------------- .../workflows/auto-merge-dependabot-pr.yml | 15 +++++ 2 files changed, 15 insertions(+), 59 deletions(-) delete mode 100644 .github/workflows/auto-merge-dependabot-nx-pr.yml create mode 100644 .github/workflows/auto-merge-dependabot-pr.yml diff --git a/.github/workflows/auto-merge-dependabot-nx-pr.yml b/.github/workflows/auto-merge-dependabot-nx-pr.yml deleted file mode 100644 index 6fc4c9d8..00000000 --- a/.github/workflows/auto-merge-dependabot-nx-pr.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Auto merge dependabot and NX PRs -on: - pull_request_target: -jobs: - auto-merge-dependabot-pr: - if: >- - github.event.pull_request.user.login == 'dependabot[bot]' && - ( - startsWith(github.head_ref, 'dependabot/npm_and_yarn/angular-') || - startsWith(github.head_ref, 'dependabot/npm_and_yarn/onecx-') || - startsWith(github.event.pull_request.title, 'chore(deps-dev)') - ) - runs-on: ubuntu-latest - steps: - - name: Auto Approve - uses: actions/github-script@v4 - with: - script: | - const result = await github.pulls.createReview({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.issue.number, - event: "APPROVE" - }) - - name: Enable auto-merge for Dependabot PRs - run: gh pr merge --auto --squash "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - rebase-merge-nx-pr: - name: Rebase and merge - runs-on: ubuntu-latest - if: github.event.pull_request.user.login == 'tkit-dev' && startsWith(github.head_ref, 'migrate-nx-to-') - steps: - - name: Checkout the latest code - uses: actions/checkout@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - fetch-depth: 0 # otherwise, you will fail to push refs to dest repo - - name: Automatic Rebase - uses: cirrus-actions/rebase@1.8 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Auto Approve - uses: actions/github-script@v4 - with: - script: | - const result = await github.pulls.createReview({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.issue.number, - event: "APPROVE" - }) - - name: Enable auto-merge for NX PRs - run: gh pr merge --auto --squash "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file diff --git a/.github/workflows/auto-merge-dependabot-pr.yml b/.github/workflows/auto-merge-dependabot-pr.yml new file mode 100644 index 00000000..2a797813 --- /dev/null +++ b/.github/workflows/auto-merge-dependabot-pr.yml @@ -0,0 +1,15 @@ +name: Auto merge dependabot Angular PRs +on: + pull_request_target: + types: [opened] +jobs: + auto-merge: + if: github.event.pull_request.user.login == 'dependabot' && startsWith(github.head_ref, 'dependabot/npm_and_yarn/angular-') + runs-on: ubuntu-latest + steps: + - name: Enable auto-merge for Dependabot PRs + if: ${{ contains(github.event.pull_request.title, 'bump')}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}