Skip to content

Commit

Permalink
CI: automated go.mod updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dex4er committed Jan 2, 2025
1 parent 3c7048c commit 5778d11
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 3 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/go-get-update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Go get update

on:
push:
branches:
- main
paths:
- go.mod
- go.sum
schedule:
- cron: 58 4 * * *
workflow_dispatch: {}

permissions:
contents: write
pull-requests: write

jobs:
go-get-update:
name: go get update

runs-on: ubuntu-24.04
environment: autoupdates

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Go get update
run: go get -u

- 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 go get update
new_branch: update/go-get-update
push: origin update/go-get-update --set-upstream --force

- name: Create pull request
if: env.changes == 'true'
uses: devops-infra/action-pull-request@master
with:
github_token: ${{ secrets.GH_TOKEN }}
target_branch: main
label: automated
title: Automated go get update
get_diff: true
65 changes: 65 additions & 0 deletions .github/workflows/go-mod-tidy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Go mod tidy

on:
push:
branches:
- main
paths:
- go.mod
- go.sum
schedule:
- cron: 48 4 * * *
workflow_dispatch: {}

permissions:
contents: write
pull-requests: write

jobs:
go-mod-tidy:
name: go mod tidy

runs-on: ubuntu-24.04
environment: autoupdates

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Go mod tidy
run: go mod tidy

- 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 go mod tidy
new_branch: update/go-mod-tidy
push: origin update/go-mod-tidy --set-upstream --force

- name: Create pull request
if: env.changes == 'true'
uses: devops-infra/action-pull-request@master
with:
github_token: ${{ secrets.GH_TOKEN }}
target_branch: main
label: automated
title: Automated go mod tidy
get_diff: true
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
id-token: write
contents: write

runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
id-token: write
contents: write

runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- name: Checkout
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ on:
jobs:
trunk:
name: Trunk Check
runs-on: ubuntu-latest

runs-on: ubuntu-24.04

steps:
- name: Checkout
Expand Down

0 comments on commit 5778d11

Please sign in to comment.