forked from paketo-buildpacks/httpd
-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (82 loc) · 3.07 KB
/
update-go-mod-version.yml
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
93
name: Update Go version
on:
schedule:
- cron: '48 4 * * MON' # every monday at 4:48 UTC
workflow_dispatch:
concurrency: update-go
jobs:
update-go:
name: Update go toolchain in go.mod
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Checkout PR Branch
uses: initializ-buildpacks/github-config/actions/pull-request/checkout-branch@main
with:
branch: automations/go-mod-update/update-main
- name: Setup Go
id: setup-go
uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Get current go toolchain version
id: current-go-version
uses: initializ-buildpacks/github-config/actions/update-go-mod-version@main
with:
go-version: ${{ steps.setup-go.outputs.go-version }}
- name: Go mod tidy
run: |
#!/usr/bin/env bash
set -euo pipefail
shopt -s inherit_errexit
echo "Before running go mod tidy"
echo "head -n10 go.mod "
head -n10 go.mod
echo "git diff"
git diff
echo "Running go mod tidy"
go mod tidy
echo "After running go mod tidy"
echo "head -n10 go.mod "
head -n10 go.mod
echo "git diff"
git diff
- name: Commit
id: commit
uses: initializ-buildpacks/github-config/actions/pull-request/create-commit@main
with:
message: "Updates go mod version to ${{ steps.setup-go.outputs.go-version }}"
pathspec: "."
keyid: ${{ secrets.INITIALIZ_BOT_GPG_SIGNING_KEY_ID }}
key: ${{ secrets.INITIALIZ_BOT_GPG_SIGNING_KEY }}
- name: Push Branch
if: ${{ steps.commit.outputs.commit_sha != '' }}
uses: initializ-buildpacks/github-config/actions/pull-request/push-branch@main
with:
branch: automations/go-mod-update/update-main
- name: Open Pull Request
if: ${{ steps.commit.outputs.commit_sha != '' }}
uses: initializ-buildpacks/github-config/actions/pull-request/open@main
with:
token: ${{ secrets.PAT }}
title: "Updates go mod version to ${{ steps.setup-go.outputs.go-version }}"
branch: automations/go-mod-update/update-main
failure:
name: Alert on Failure
runs-on: ubuntu-22.04
needs: [update-go]
if: ${{ always() && needs.update-go.result == 'failure' }}
steps:
- name: File Failure Alert Issue
uses: initializ-buildpacks/github-config/actions/issue/file@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
repo: ${{ github.repository }}
label: "failure:update-go-version"
comment_if_exists: true
issue_title: "Failure: Update Go Mod Version workflow"
issue_body: |
Update Go Mod Version workflow [failed](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}).
comment_body: |
Another failure occurred: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}