From 0ae2610d38febe8f95b54d4c764f2c8d015cd489 Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Fri, 6 Sep 2024 11:31:34 +0200 Subject: [PATCH 01/12] 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 02/12] 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}} From 6b10481121fb65005acf38ea43a5e8d2680ab485 Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Fri, 6 Sep 2024 12:46:43 +0200 Subject: [PATCH 03/12] fix: add committer name and email for release job --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bef34087..5aa72547 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,3 +24,5 @@ jobs: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} GIT_AUTHOR_NAME: tkit-dev GIT_AUTHOR_EMAIL: tkit-dev@1000kit.org + GIT_COMMITTER_NAME: tkit-dev + GIT_COMMITTER_EMAIL: tkit-dev@1000kit.org From 6677b0a5900b8537391d881e4227507a0ea30a42 Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Mon, 9 Sep 2024 08:05:07 +0200 Subject: [PATCH 04/12] fix: add worklfow for auto merge dependabot and nx PRs --- .../workflows/auto-merge-dependabot-pr.yml | 56 +++++++++++++++++-- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/.github/workflows/auto-merge-dependabot-pr.yml b/.github/workflows/auto-merge-dependabot-pr.yml index 2a797813..6fc4c9d8 100644 --- a/.github/workflows/auto-merge-dependabot-pr.yml +++ b/.github/workflows/auto-merge-dependabot-pr.yml @@ -1,15 +1,59 @@ -name: Auto merge dependabot Angular PRs +name: Auto merge dependabot and NX 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-') + 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 - if: ${{ contains(github.event.pull_request.title, 'bump')}} - run: gh pr merge --auto --merge "$PR_URL" + 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 From 2f35888a6750b15c701e9e26e23878a26407af41 Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Mon, 9 Sep 2024 08:43:23 +0200 Subject: [PATCH 05/12] fix: also ignore @nx dependencies --- .github/dependabot.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f42a4ebf..f6f285dc 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -15,4 +15,5 @@ updates: - "minor" - "patch" ignore: - - dependency-name: "nx*" \ No newline at end of file + - dependency-name: "nx*" + - dependency-name: "@nx*" \ No newline at end of file From 29415776f8faae50ede58d545feff5bff55b93c3 Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Tue, 10 Sep 2024 11:51:29 +0200 Subject: [PATCH 06/12] fix: change github user and email before starting the release --- .github/workflows/release.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5aa72547..57610fdf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,6 +17,10 @@ jobs: run: npx nx run-many -t lint - name: Test run: npx nx run-many -t test --configuration=ci + - name: Change git config + run: | + gh config set user.email "tkit-dev@1000kit.org" + gh config set user.name "tkit-dev" - name: Release run: npx semantic-release env: From 6fbb2cf9f7072a9d95b1b1c4b990a97f167fce51 Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Tue, 10 Sep 2024 12:02:20 +0200 Subject: [PATCH 07/12] fix: rebase PRs --- .github/workflows/nx.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/nx.yml b/.github/workflows/nx.yml index 750d57c8..95189f6f 100644 --- a/.github/workflows/nx.yml +++ b/.github/workflows/nx.yml @@ -16,3 +16,7 @@ jobs: - uses: timonmasberg/nx-migration-gh-action@v1.1.13 with: repoToken: ${{ secrets.CI_PAT }} + - name: Rebase + uses: cirrus-actions/rebase@1.8 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 1870cb41db557ebe6c85bd8c76663eee4788f56a Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Tue, 17 Sep 2024 10:16:38 +0200 Subject: [PATCH 08/12] fix: change git config name and email --- .github/workflows/nx.yml | 5 +---- .github/workflows/release.yml | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/nx.yml b/.github/workflows/nx.yml index 95189f6f..3acefdf6 100644 --- a/.github/workflows/nx.yml +++ b/.github/workflows/nx.yml @@ -16,7 +16,4 @@ jobs: - uses: timonmasberg/nx-migration-gh-action@v1.1.13 with: repoToken: ${{ secrets.CI_PAT }} - - name: Rebase - uses: cirrus-actions/rebase@1.8 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 57610fdf..e581b4d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,8 +19,8 @@ jobs: run: npx nx run-many -t test --configuration=ci - name: Change git config run: | - gh config set user.email "tkit-dev@1000kit.org" - gh config set user.name "tkit-dev" + git config --global user.name "tkit-dev" + git config --global user.email "tkit-dev@1000kit.org" - name: Release run: npx semantic-release env: From 104ac44059d64827f25dfb4df294609c13f5f7ed Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Tue, 17 Sep 2024 10:17:37 +0200 Subject: [PATCH 09/12] fix: whitespace --- .github/workflows/nx.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/nx.yml b/.github/workflows/nx.yml index 3acefdf6..6f72b256 100644 --- a/.github/workflows/nx.yml +++ b/.github/workflows/nx.yml @@ -15,5 +15,4 @@ jobs: - run: npm ci - uses: timonmasberg/nx-migration-gh-action@v1.1.13 with: - repoToken: ${{ secrets.CI_PAT }} - \ No newline at end of file + repoToken: ${{ secrets.CI_PAT }} \ No newline at end of file From 77a2edaa93bff35f9edbecaec37bdce488fdbb38 Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Tue, 17 Sep 2024 12:05:25 +0200 Subject: [PATCH 10/12] fix: add property so its own credentials are used for release --- .github/workflows/release.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e581b4d8..5ada4794 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,7 @@ jobs: steps: - uses: actions/checkout@v4 with: + persist-credentials: false fetch-depth: 0 - uses: actions/setup-node@v4 with: @@ -17,10 +18,6 @@ jobs: run: npx nx run-many -t lint - name: Test run: npx nx run-many -t test --configuration=ci - - name: Change git config - run: | - git config --global user.name "tkit-dev" - git config --global user.email "tkit-dev@1000kit.org" - name: Release run: npx semantic-release env: From 78bd33a17d1d0a1364e6fcda585001e47ffb431f Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Tue, 17 Sep 2024 15:09:27 +0200 Subject: [PATCH 11/12] fix: remove git env tokens for author and committer --- .github/workflows/release.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ada4794..53e98b4b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,3 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - GIT_AUTHOR_NAME: tkit-dev - GIT_AUTHOR_EMAIL: tkit-dev@1000kit.org - GIT_COMMITTER_NAME: tkit-dev - GIT_COMMITTER_EMAIL: tkit-dev@1000kit.org From b152f5dd178c007bd9020754f562d6722cc2868b Mon Sep 17 00:00:00 2001 From: Kim Tran Date: Tue, 17 Sep 2024 15:47:35 +0200 Subject: [PATCH 12/12] fix: use different token for release --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 53e98b4b..0693c6e1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,5 +21,5 @@ jobs: - name: Release run: npx semantic-release env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.CI_PAT }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}