Skip to content

Commit 22c06a4

Browse files
authored
chore: update gh action to auto merge disposable phone numbers PRs (#147)
1 parent 8140c0b commit 22c06a4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

.github/workflows/update-disposable-phone-numbers.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ jobs:
3535
echo "Latest version available: $LATEST_VERSION"
3636
echo "Current version in package.json: $CURRENT_VERSION"
3737
38+
- name: Close existing PR if it exists
39+
if: steps.versions.outputs.latest_version != steps.versions.outputs.current_version
40+
run: |
41+
# Check if PR exists and close it
42+
if gh pr list --head "chore/update-disposable-phone-numbers" --json number --jq '.[0].number' | grep -q .; then
43+
PR_NUMBER=$(gh pr list --head "chore/update-disposable-phone-numbers" --json number --jq '.[0].number')
44+
echo "Closing existing PR #$PR_NUMBER"
45+
gh pr close "$PR_NUMBER"
46+
else
47+
echo "No existing PR found"
48+
fi
49+
env:
50+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
3852
- name: Update package if version has changed
3953
if: steps.versions.outputs.latest_version != steps.versions.outputs.current_version
4054
run: |
@@ -57,6 +71,12 @@ jobs:
5771
delete-branch: true
5872
base: "main"
5973

74+
- name: Auto-approve the PR
75+
if: steps.create-pr.outputs.pull-request-number
76+
run: gh pr review --approve "${{ steps.create-pr.outputs.pull-request-number }}"
77+
env:
78+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
6080
- name: Enable automerge on the PR
6181
if: steps.create-pr.outputs.pull-request-number
6282
run: gh pr merge --auto --squash "${{ steps.create-pr.outputs.pull-request-number }}"

0 commit comments

Comments
 (0)