From 5778d116d206eb7d438f60006ca4a5d1f61a1d33 Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Thu, 2 Jan 2025 19:06:53 +0100 Subject: [PATCH] CI: automated go.mod updates --- .github/workflows/go-get-update.yaml | 65 ++++++++++++++++++++++++++++ .github/workflows/go-mod-tidy.yaml | 65 ++++++++++++++++++++++++++++ .github/workflows/release.yaml | 2 +- .github/workflows/snapshot.yaml | 2 +- .github/workflows/trunk.yaml | 3 +- 5 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/go-get-update.yaml create mode 100644 .github/workflows/go-mod-tidy.yaml diff --git a/.github/workflows/go-get-update.yaml b/.github/workflows/go-get-update.yaml new file mode 100644 index 0000000..6fd7749 --- /dev/null +++ b/.github/workflows/go-get-update.yaml @@ -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 diff --git a/.github/workflows/go-mod-tidy.yaml b/.github/workflows/go-mod-tidy.yaml new file mode 100644 index 0000000..99e0985 --- /dev/null +++ b/.github/workflows/go-mod-tidy.yaml @@ -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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 45d7c5c..be70cac 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -17,7 +17,7 @@ jobs: id-token: write contents: write - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Checkout diff --git a/.github/workflows/snapshot.yaml b/.github/workflows/snapshot.yaml index c00fadd..39024ee 100644 --- a/.github/workflows/snapshot.yaml +++ b/.github/workflows/snapshot.yaml @@ -24,7 +24,7 @@ jobs: id-token: write contents: write - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Checkout diff --git a/.github/workflows/trunk.yaml b/.github/workflows/trunk.yaml index b81c5a9..ed59644 100644 --- a/.github/workflows/trunk.yaml +++ b/.github/workflows/trunk.yaml @@ -8,7 +8,8 @@ on: jobs: trunk: name: Trunk Check - runs-on: ubuntu-latest + + runs-on: ubuntu-24.04 steps: - name: Checkout