forked from k8s-operatorhub/community-operators
-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (104 loc) · 4.53 KB
/
command_merge.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
on: issue_comment
name: Issue Comments - merge
env:
OPP_PRODUCTION_TYPE: "k8s"
jobs:
handle_comments:
name: Check comments for /merge
if: |
startsWith(github.event.comment.body, '/merge')
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v4
id: labels
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labels = await github.issues.listLabelsOnIssue({
issue_number: context.payload.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
})
console.log(labels.data)
return labels.data
# - name: Print info about event
# id: info
# continue-on-error: true
# uses: actions/github-script@v3
# with:
# github-token: ${{secrets.GITHUB_TOKEN}}
# script: |
# console.log(context)
# console.log(`::set-output name=xxx::${context.payload.issue.labels}`)
- name: Merge command handler
id: command
uses: xt0rted/slash-command-action@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
command: merge
reaction: "true"
reaction-type: "eyes"
allow-edits: "false"
permission-level: write
- name: Merge message when not able to merge and inform user about authorized_changes
uses: actions/github-script@v3
if: |
steps.command.outputs.command-name == 'merge' &&
steps.command.outputs.command-arguments == 'possible' &&
(!contains(fromJSON(steps.labels.outputs.result).*.name, 'authorized-changes')) &&
(contains(fromJSON(steps.labels.outputs.result).*.name, 'installation-validated')) &&
(contains(fromJSON(steps.labels.outputs.result).*.name, 'package-validated')) &&
(!contains(fromJSON(steps.labels.outputs.result).*.name, 'new-operator')) &&
(!contains(fromJSON(steps.labels.outputs.result).*.name, 'do-not-merge/work-in-progress')) &&
(!contains(fromJSON(steps.labels.outputs.result).*.name, 'do-not-merge/hold'))
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Current PR can be merged automatically, but there is missing `authorized-changes` label. One can find out more info [here](https://operator-framework.github.io/community-operators/operator-ci-yaml/#reviewers).'
})
- name: Message when automerge is disabled
uses: actions/github-script@v3
if: |
steps.command.outputs.command-name == 'merge' &&
steps.command.outputs.command-arguments == 'possible' &&
(contains(fromJSON(steps.labels.outputs.result).*.name, 'automerge-disabled'))
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Automatic merge is disabled temporarily due to a maintenance.'
})
- name: Message when dco-failed is missing
uses: actions/github-script@v3
if: |
steps.command.outputs.command-name == 'merge' &&
steps.command.outputs.command-arguments == 'possible' &&
(contains(fromJSON(steps.labels.outputs.result).*.name, 'dco-failed'))
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'DCO is missing. Please signoff your commits !!!'
})
- name: automerge
if: steps.command.outputs.command-name == 'merge' && steps.command.outputs.command-arguments == 'possible'
uses: "pascalgn/[email protected]"
env:
GITHUB_TOKEN: "${{ secrets.FRAMEWORK_MERGE }}"
MERGE_LABELS: "authorized-changes,package-validated,installation-validated,!do-not-merge/hold,!do-not-merge/work-in-progress,!automerge-disabled,!dco-failed"
MERGE_REMOVE_LABELS: ""
MERGE_METHOD: "squash"
MERGE_COMMIT_MESSAGE: "pull-request-title"
MERGE_FORKS: "true"
MERGE_RETRIES: "6"
MERGE_RETRY_SLEEP: "10000"