-
Notifications
You must be signed in to change notification settings - Fork 15
/
update_pipeline.go
85 lines (79 loc) · 2.98 KB
/
update_pipeline.go
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
/*
* Copyright 2018-2020 the original author or 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
*
* https://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.
*/
package octo
import (
"fmt"
"path/filepath"
"github.com/paketo-buildpacks/pipeline-builder/octo/actions"
"github.com/paketo-buildpacks/pipeline-builder/octo/actions/event"
)
func ContributeUpdatePipeline(descriptor Descriptor) (Contribution, error) {
w := actions.Workflow{
Name: "Update Pipeline",
On: map[event.Type]event.Event{
event.PushType: event.Push{
Branches: []string{"main"},
Paths: []string{filepath.Join(".github", "pipeline-descriptor.yml")},
},
event.ScheduleType: event.Schedule{{Minute: "0", Hour: "5", DayOfWeek: "1-5"}},
event.WorkflowDispatchType: event.WorkflowDispatch{},
},
Jobs: map[string]actions.Job{
"update": {
Name: "Update Pipeline",
RunsOn: []actions.VirtualEnvironment{actions.UbuntuLatest},
Steps: []actions.Step{
{
Uses: "actions/setup-go@v3",
With: map[string]interface{}{"go-version": GoVersion},
},
{
Name: "Install octo",
Run: StatikString("/install-octo.sh"),
},
{
Uses: "actions/checkout@v3",
},
{
Id: "pipeline",
Name: "Update Pipeline",
Run: StatikString("/update-pipeline.sh"),
Env: map[string]string{
"GITHUB_TOKEN": descriptor.GitHub.Token,
"DESCRIPTOR": filepath.Join(".github", "pipeline-descriptor.yml"),
},
},
{
Uses: "peter-evans/create-pull-request@v4",
With: map[string]interface{}{
"token": descriptor.GitHub.Token,
"author": fmt.Sprintf("%[1]s <%[1]s@users.noreply.github.com>", descriptor.GitHub.Username),
"commit-message": `Bump pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }}
Bumps pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }}.`,
"signoff": true,
"branch": "update/pipeline",
"delete-branch": true,
"title": "Bump pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }}",
"body": "Bumps pipeline from `${{ steps.pipeline.outputs.old-version }}` to `${{ steps.pipeline.outputs.new-version }}`.\n\n<details>\n<summary>Release Notes</summary>\n${{ steps.pipeline.outputs.release-notes }}\n</details>",
"labels": "semver:patch, type:task",
},
},
},
},
},
}
return NewActionContribution(w)
}