Skip to content

Commit c27abe0

Browse files
authored
[GitHub] [Chore] Add automatic add approve label (apache#3354)
[GitHub] [Chore] Add automatic add approve label
1 parent da33f73 commit c27abe0

6 files changed

+101
-0
lines changed

.github/actions/get-workflow-origin

Submodule get-workflow-origin added at 751d472
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
19+
name: Label-when-reviewed
20+
on: pull_request_review
21+
jobs:
22+
23+
label-when-reviewed:
24+
name: "Label PRs when reviewed"
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: "Do nothing. Only trigger corresponding workflow_run event"
28+
run: echo

.github/workflows/approve-label.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
19+
name: "Label when approved workflow run"
20+
on:
21+
workflow_run:
22+
workflows: [Label-when-reviewed]
23+
types: [requested]
24+
permissions:
25+
# All other permissions are set to none
26+
checks: write
27+
contents: read
28+
pull-requests: write
29+
jobs:
30+
label-when-approved:
31+
name: "Label when approved"
32+
runs-on: ubuntu-latest
33+
outputs:
34+
isApprovedByCommiters: ${{ steps.label-when-approved-by-commiters.outputs.isApproved }}
35+
isApprovedByAnyone: ${{ steps.label-when-approved-by-anyone.outputs.isApproved }}
36+
steps:
37+
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
38+
uses: actions/checkout@v2
39+
with:
40+
persist-credentials: false
41+
submodules: recursive
42+
- name: "Get information about the original trigger of the run"
43+
uses: ./.github/actions/get-workflow-origin
44+
id: source-run-info
45+
with:
46+
token: ${{ secrets.GITHUB_TOKEN }}
47+
sourceRunId: ${{ github.event.workflow_run.id }}
48+
- name: Label when approved by commiters
49+
uses: ./.github/actions/label-when-approved-action
50+
id: label-when-approved-by-commiters
51+
with:
52+
token: ${{ secrets.GITHUB_TOKEN }}
53+
label: 'approved'
54+
require_committers_approval: 'true'
55+
remove_label_when_approval_missing: 'true'
56+
pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }}
57+
- name: Label when approved by anyone
58+
uses: ./.github/actions/label-when-approved-action
59+
id: label-when-approved-by-anyone
60+
with:
61+
token: ${{ secrets.GITHUB_TOKEN }}
62+
label: 'reviewed'
63+
pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }}

.gitmodules

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule ".github/actions/get-workflow-origin"]
2+
path = .github/actions/get-workflow-origin
3+
url = https://github.com/potiuk/get-workflow-origin.git
4+
[submodule ".github/actions/label-when-approved-action"]
5+
path = .github/actions/label-when-approved-action
6+
url = https://github.com/TobKed/label-when-approved-action

.licenserc.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ header:
2727
- DISCLAIMER
2828
- mvnw.cmd
2929
- .mvn
30+
- .gitmodules
3031
- .gitattributes
32+
- .github/actions
3133
- '**/known-dependencies-*.txt'
3234
- '**/*.md'
3335
- '**/*.mdx'

0 commit comments

Comments
 (0)