Skip to content

Automated trunk upgrade #7

Automated trunk upgrade

Automated trunk upgrade #7

name: Automated trunk upgrade
on:
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
steps:
- name: Checkout
uses: actions/checkout@v4
- 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 '1,/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: 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
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
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 }}