-
Notifications
You must be signed in to change notification settings - Fork 8
106 lines (97 loc) · 4.32 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
on: issue_comment
name: Issue Comments - merge
env:
OPP_PRODUCTION_TYPE: "k8s"
OPP_THIS_REPO_NAME: "community-operators-pipeline"
OPP_THIS_REPO_ORG: "redhat-openshift-ecosystem"
jobs:
handle_comments:
name: Check comments for /merge
if: |
startsWith(github.event.comment.body, '/merge')
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
id: labels
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labels = await github.rest.issues.listLabelsOnIssue({
issue_number: context.payload.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
})
console.log(labels.data)
return labels.data
- 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@v6
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.rest.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://${OPP_THIS_REPO_ORG}.github.io/${OPP_THIS_REPO_NAME}/operator-ci-yaml/#reviewers).'
})
- name: Message when automerge is disabled
uses: actions/github-script@v6
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.rest.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@v6
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.rest.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"