Skip to content

Commit b544994

Browse files
committed
chore(ci): fix workflow automation
1 parent 91089b5 commit b544994

File tree

5 files changed

+53
-33
lines changed

5 files changed

+53
-33
lines changed

.github/workflows/audit-fix-auto-merge.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.github/workflows/audit-fix.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ jobs:
2626
run: npm ci
2727

2828
- name: Run npm audit fix
29-
run: npm audit fix || npm audit fix --force || true
29+
run: |
30+
npm audit 2>&1 > audit-report.txt || true
31+
npm audit fix || npm audit fix --force || true
3032
3133
- name: Create pull request
3234
env:
@@ -38,17 +40,27 @@ jobs:
3840
exit 0
3941
fi
4042
41-
BRANCH="npm-audit-fix-$(date +%Y%m%d)"
43+
BRANCH="npm-audit-fix-$(date +%Y%m%d-%H%M%S)"
4244
git config user.name "github-actions[bot]"
4345
git config user.email "github-actions[bot]@users.noreply.github.com"
4446
git checkout -b "$BRANCH"
4547
git add package.json package-lock.json
4648
git commit -m "chore(deps): npm audit fix"
4749
git push origin "$BRANCH"
4850
51+
cat > pr-body.md << 'BODYEOF'
52+
Automated security fixes via `npm audit fix`.
53+
54+
## Audit Report
55+
56+
```
57+
BODYEOF
58+
cat audit-report.txt >> pr-body.md
59+
echo '```' >> pr-body.md
60+
4961
gh pr create \
5062
--title "chore(deps): npm audit fix" \
51-
--body "Automated security fixes via \`npm audit fix\`." \
63+
--body-file pr-body.md \
5264
--label "audit: fix" \
5365
--base main \
5466
--head "$BRANCH"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Auto approve and merge
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- labeled
7+
- opened
8+
- synchronize
9+
- reopened
10+
- ready_for_review
11+
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
jobs:
17+
auto-merge:
18+
name: Auto approve and merge
19+
runs-on: ubuntu-latest
20+
if: "github.actor == 'dependabot[bot]' || (github.event.pull_request.user.login == 'github-actions[bot]' && contains(github.event.pull_request.labels.*.name, 'audit: fix'))"
21+
steps:
22+
- name: Approve
23+
run: gh pr review "$PR_NUMBER" --approve
24+
env:
25+
PR_NUMBER: ${{ github.event.number }}
26+
GH_TOKEN: ${{ secrets.LOCALSTACK_BOT_TOKEN }}
27+
- name: Enable auto-merge
28+
run: gh pr merge "$PR_NUMBER" --auto --squash
29+
env:
30+
PR_NUMBER: ${{ github.event.number }}
31+
GH_TOKEN: ${{ secrets.LOCALSTACK_BOT_TOKEN }}

.github/workflows/pull-request-lint.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
name: Pull Request Lint
22

33
on:
4-
pull_request:
5-
branches: ["main"]
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- reopened
69

710
jobs:
811
validate:
912
name: Validate PR title
1013
runs-on: ubuntu-latest
1114
permissions:
12-
pull-requests: write
15+
pull-requests: read
1316
steps:
1417
- uses: amannn/action-semantic-pull-request@v6
1518
env:

.github/workflows/release-auto-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
--json number \
2626
--jq '.[].number' | \
2727
while read -r pr; do
28-
echo "Enabling auto-merge on PR #$pr"
28+
echo "Approving and enabling auto-merge on PR #$pr"
2929
gh pr review "$pr" --approve --comment --body "Auto-approve weekly releases"
3030
gh pr merge "$pr" --auto --squash
3131
done

0 commit comments

Comments
 (0)