Skip to content

Commit a71a186

Browse files
committed
updated ci with automerge dependabot green PRs
1 parent d631dfc commit a71a186

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ jobs:
5151
github_token: ${{ secrets.GITHUB_TOKEN }}
5252
publish_dir: .
5353

54+
dependabot:
55+
name: 'Dependabot'
56+
needs: build # After the E2E and build jobs, if one of them fails, it won't merge the PR.
57+
runs-on: ubuntu-latest
58+
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}} # Detect that the PR author is dependabot
59+
steps:
60+
- name: Enable auto-merge for Dependabot PRs
61+
run: gh pr merge --auto --merge "$PR_URL" # Use Github CLI to merge automatically the PR
62+
env:
63+
PR_URL: ${{github.event.pull_request.html_url}}
64+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
65+
5466
npm-publish-build:
5567
needs: build
5668
runs-on: ubuntu-latest
@@ -66,14 +78,14 @@ jobs:
6678
run: 'sed -i -E "s/(\"version\": *\"[^\"]+)/\1-${GITHUB_SHA_SHORT}/" package.json'
6779
- name: Disable pre- and post-publish actions
6880
run: 'sed -i -E "s/\"((pre|post)publish)/\"ignore:\1/" package.json'
69-
- uses: JS-DevTools/npm-publish@v3.1.1
81+
- uses: JS-DevTools/npm-publish@v4.1.0
7082
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
7183
with:
7284
token: ${{ secrets.NPM_TOKEN }}
7385
tag: ${{ env.GITHUB_REF_SLUG }}
7486

7587
npm-publish-latest:
76-
needs: build
88+
needs: [build, npm-publish-build]
7789
runs-on: ubuntu-latest
7890
if: github.ref == 'refs/heads/main'
7991
steps:
@@ -85,7 +97,7 @@ jobs:
8597
node-version: 20.x
8698
- name: Disable pre- and post-publish actions
8799
run: 'sed -i -E "s/\"((pre|post)publish)/\"ignore:\1/" package.json'
88-
- uses: JS-DevTools/npm-publish@v3.1.1
100+
- uses: JS-DevTools/npm-publish@v4.1.0
89101
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
90102
with:
91103
token: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)