-
Notifications
You must be signed in to change notification settings - Fork 51
148 lines (122 loc) · 4.39 KB
/
auto-update-gofmt.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Copyright 2021 The Knative Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##
## This file is auto-generated from actions/update-gofmt/auto-apply.yaml
## by ./cmd/gen-actions
##
name: Run Gofmt and Goimport
on:
schedule:
- cron: '0 1,13 * * 1-5' # 6am/pm Pacific on weekdays
workflow_dispatch:
inputs:
only-repo:
description: "Only autogenerate a single repo (exact match)?"
reason:
description: "Justification?"
required: true
jobs:
meta:
runs-on: ubuntu-latest
outputs:
includes: ${{ steps.load-matrix.outputs.includes }}
names: ${{ steps.load-matrix.outputs.names }}
steps:
- name: Check out knobots configuration
uses: actions/checkout@v4
- name: Calculate affected repos
id: load-matrix
uses: "./actions/calculate-matrix"
with:
action-name: gofmt
only-repo: ${{ github.event.inputs.only-repo }}
apply-change:
name: "Apply Change" # TODO: from metadata?
needs: meta
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
matrix:
name: ${{ fromJson(needs.meta.outputs.names) }}
include: ${{ fromJson(needs.meta.outputs.includes) }}
steps:
- name: Checkout config code
uses: actions/checkout@v4
with:
path: config
- name: Checkout ${{ matrix.name }} code
uses: actions/checkout@v4
with:
path: main
repository: ${{ matrix.name }}
# This is required because the branch setting might be empty (to infer a default), so
# after checkout we fetch what the checkout action decided to check out.
- name: Infer branch from checkout
id: inferbranch
run: |
cd main
echo "branch=$(git branch --show-current)" >> $GITHUB_OUTPUT
- name: Apply work
id: work
uses: "./config/actions/update-gofmt"
with:
repo: ${{ matrix.name }}
organization: ${{ matrix.meta-organization }}
include: ${{ matrix.include }}
- name: Create Pull Request
id: cpr
if: ${{ env.create_pr == 'true' }}
uses: peter-evans/create-pull-request@v7
with:
# Who to look like
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
committer: "Knative Automation <[email protected]>"
author: "Knative Automation <[email protected]>"
# Where to stage the change
push-to-fork: ${{ matrix.fork }}
branch: auto-updates/update-gofmt-${{ steps.inferbranch.outputs.branch }}
signoff: true
delete-branch: true
# What labels to add
labels: ${{ env.pr_labels }}
# Note this is hard-coded based on the added repos in main.go
path: main
commit-message: |
Format go code
${{ steps.work.outputs.log }}
title: "[${{ steps.inferbranch.outputs.branch }}] Format Go code"
body: |
${{ github.event.inputs.reason || 'Cron' }} -${{ github.actor }}
/cc ${{ matrix.assignees }}
/assign ${{ matrix.assignees }}
Produced by: ${{ github.repository }}/actions/update-gofmt
Details:
```
${{ steps.work.outputs.log }}
```
- name: Report error
uses: rtCamp/action-slack-notify@v2
if: ${{ failure() }}
env:
SLACK_ICON: http://github.com/knative-automation.png?size=48
SLACK_USERNAME: knative-automation
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: ${{ matrix.channel }}
SLACK_COLOR: '#8E1600'
MSG_MINIMAL: 'true'
SLACK_TITLE: "[${{ steps.inferbranch.outputs.branch }}] Format Go code for ${{ matrix.name }} failed."
SLACK_MESSAGE: |
For detailed logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
${{ github.event.inputs.reason || 'Cron' }} -${{ github.actor }}