-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (78 loc) · 2.52 KB
/
trunk-upgrade.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Automated trunk upgrade
on:
issue_comment:
types:
- created
push:
branches:
- main
paths:
- .trunk/**
schedule:
- cron: 38 4 * * *
workflow_dispatch: {}
permissions:
contents: write
pull-requests: write
jobs:
trunk-upgrade:
name: trunk upgrade
runs-on: ubuntu-24.04
environment: automated
if: >-
github.event_name != 'issue_comment' ||
contains(github.event.comment.body, '/rerun')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Set up Trunk
run: curl https://get.trunk.io -fsSL | bash -s -- -y
- name: Trunk upgrade
run: |
trunk upgrade --yes-to-all --no-progress --ci --color | tee .github/update.log
sed -e '/Downloading Trunk/,/Unpacking Trunk... done/d' -e 's/\x1b\[[0-9;]*m//g' -e 's/^\( \)\{0,1\} /\1- /' .github/update.log > .github/pr_body.log
- name: Check for changes
run: |
if git diff --exit-code; then
echo "changes=false" >> $GITHUB_ENV
else
echo "changes=true" >> $GITHUB_ENV
fi
- name: Trunk Check
if: env.changes == 'true'
uses: trunk-io/trunk-action@v1
with:
check-mode: all
continue-on-error: true
- name: Commit and push to branch
if: env.changes == 'true'
uses: EndBug/add-and-commit@v9
with:
github_token: ${{ secrets.GH_TOKEN }}
default_author: github_actions
message: Automated trunk upgrade [skip ci]
new_branch: automated/trunk-upgrade
fetch: false
push: origin automated/trunk-upgrade --set-upstream --force
- name: Create pull request
id: pr
if: env.changes == 'true'
uses: devops-infra/action-pull-request@master
with:
github_token: ${{ secrets.GH_TOKEN }}
target_branch: main
label: automated
title: Automated trunk upgrade [skip ci]
get_diff: false
- name: Update pull request description
if: env.changes == 'true'
run: gh pr edit ${{ steps.pr.outputs.pr_number }} --body-file .github/pr_body.log
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Close pull request
if: env.changes == 'false'
run: gh pr list --head automated/trunk-upgrade --json number --jq '.[].number' | xargs -rn1 gh pr close --delete-branch
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}