Skip to content

Commit bd3c5fa

Browse files
chore: Upgrade trunk (#31)
[![Trunk](https://static.trunk.io/assets/trunk_action_upgrade_banner.png)](https://trunk.io) 3 linters were upgraded: - checkov 3.2.447 β†’ 3.2.457 - trivy 0.63.0 β†’ 0.64.1 - trufflehog 3.89.2 β†’ 3.90.2 This PR was generated by the [Trunk Action]. For more info, see our [docs] or reach out on [Slack]. [Trunk Action]: https://github.com/trunk-io/trunk-action [docs]: https://docs.trunk.io [Slack]: https://slack.trunk.io/ --------- Co-authored-by: gberenice <30597968+gberenice@users.noreply.github.com> Co-authored-by: Veronika Gnilitska <veronika.gnilitska@gmail.com>
1 parent df8bb71 commit bd3c5fa

2 files changed

Lines changed: 82 additions & 5 deletions

File tree

β€Ž.github/workflows/trunk-upgrade.yamlβ€Ž

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
pull-requests: write
1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2121

2222
- name: Create Token for MasterpointBot App
2323
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a #v2.1.0
@@ -27,8 +27,85 @@ jobs:
2727
private_key: ${{ secrets.MP_BOT_APP_PRIVATE_KEY }}
2828

2929
- name: Upgrade
30-
uses: trunk-io/trunk-action/upgrade@4d5ecc89b2691705fd08c747c78652d2fc806a94 #v1.1.19
30+
id: trunk-upgrade
31+
uses: trunk-io/trunk-action/upgrade@4d5ecc89b2691705fd08c747c78652d2fc806a94 # v1.1.19
3132
with:
3233
github-token: ${{ steps.generate-token.outputs.token }}
3334
reviewers: "@masterpointio/masterpoint-internal"
3435
prefix: "chore: "
36+
37+
- name: Wait for checks to pass + Merge PR
38+
if: steps.trunk-upgrade.outputs.pull-request-number != ''
39+
env:
40+
GH_TOKEN: ${{ secrets.MASTERPOINT_TEAM_PAT }}
41+
PR_NUMBER: ${{ steps.trunk-upgrade.outputs.pull-request-number }}
42+
run: |
43+
echo "Waiting for status checks to pass on PR #$PR_NUMBER..."
44+
45+
# Wait a bit for checks to start
46+
echo "Waiting 30 seconds for checks to initialize..."
47+
sleep 30
48+
49+
# Try to get all checks first to see if any exist
50+
ALL_CHECKS_JSON=$(gh pr checks "$PR_NUMBER" --json state,bucket || echo "[]")
51+
echo "All checks: $ALL_CHECKS_JSON"
52+
53+
# Get required checks
54+
REQUIRED_CHECKS_JSON=$(gh pr checks "$PR_NUMBER" --required --json state,bucket || echo "[]")
55+
echo "Required checks: $REQUIRED_CHECKS_JSON"
56+
57+
# Check if we have any required checks
58+
REQUIRED_CHECKS_COUNT=$(echo "$REQUIRED_CHECKS_JSON" | jq '. | length')
59+
ALL_CHECKS_COUNT=$(echo "$ALL_CHECKS_JSON" | jq '. | length')
60+
61+
if [ "$REQUIRED_CHECKS_COUNT" -eq 0 ] && [ "$ALL_CHECKS_COUNT" -eq 0 ]; then
62+
echo "No status checks found. This might be expected if no checks are configured."
63+
echo "Proceeding with auto-approval and merge..."
64+
65+
# Auto-approve the PR
66+
gh pr review "$PR_NUMBER" --approve --body "Auto-approved by trunk upgrade workflow (no status checks configured)"
67+
68+
# Merge the PR
69+
gh pr merge "$PR_NUMBER" --squash --delete-branch --admin
70+
exit 0
71+
fi
72+
73+
# If we have required checks, wait for them. Otherwise, wait for all checks.
74+
if [ "$REQUIRED_CHECKS_COUNT" -gt 0 ]; then
75+
echo "Waiting for $REQUIRED_CHECKS_COUNT required status checks..."
76+
CHECKS_TO_MONITOR="required"
77+
else
78+
echo "No required checks configured. Waiting for all $ALL_CHECKS_COUNT status checks..."
79+
CHECKS_TO_MONITOR="all"
80+
fi
81+
82+
# Wait for checks to complete
83+
while true; do
84+
if [ "$CHECKS_TO_MONITOR" = "required" ]; then
85+
CHECKS_JSON=$(gh pr checks "$PR_NUMBER" --required --json state,bucket)
86+
else
87+
CHECKS_JSON=$(gh pr checks "$PR_NUMBER" --json state,bucket)
88+
fi
89+
90+
echo "Current checks status: $CHECKS_JSON"
91+
92+
if echo "$CHECKS_JSON" | jq -e '.[] | select(.bucket=="fail")' > /dev/null; then
93+
echo "One or more checks have failed. Exiting..."
94+
exit 1
95+
fi
96+
97+
FAILED_OR_PENDING_CHECKS=$(echo "$CHECKS_JSON" | jq '[.[] | select(.state!="SUCCESS" or .bucket!="pass")] | length')
98+
if [ "$FAILED_OR_PENDING_CHECKS" -eq 0 ]; then
99+
echo "All checks passed. Auto-approving and merging PR https://github.com/${{ github.repository }}/pull/$PR_NUMBER..."
100+
101+
# Auto-approve the PR
102+
gh pr review "$PR_NUMBER" --approve --body "Auto-approved by trunk upgrade workflow"
103+
104+
# Merge the PR
105+
gh pr merge "$PR_NUMBER" --squash --delete-branch --admin
106+
break
107+
else
108+
echo "Some checks are still running or pending. Retrying in 30s..."
109+
sleep 30
110+
fi
111+
done

β€Ž.trunk/trunk.yamlβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ plugins:
99
lint:
1010
enabled:
1111
- actionlint@1.7.7
12-
- checkov@3.2.447
13-
- trivy@0.63.0
12+
- checkov@3.2.457
13+
- trivy@0.64.1
1414
- yamllint@1.37.1
1515
- git-diff-check
1616
- markdownlint@0.45.0
1717
- prettier@3.6.2
18-
- trufflehog@3.89.2
18+
- trufflehog@3.90.2
1919
ignore:
2020
- linters: [ALL]
2121
paths:

0 commit comments

Comments
Β (0)