Skip to content

Commit 90ee3e8

Browse files
authored
CI: GitHub Action to automate license checks (#3)
* Add GHA to automate license checks
1 parent 343c451 commit 90ee3e8

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
---
16+
name: addlicense
17+
18+
on: # yamllint disable-line rule:truthy
19+
pull_request: null
20+
21+
permissions:
22+
contents: read
23+
24+
jobs:
25+
addlicense:
26+
permissions:
27+
contents: write
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Pull container for addlicense
35+
run: docker pull ghcr.io/google/addlicense:latest
36+
37+
- name: invoke addlicense
38+
run: docker run -v "${PWD}":/src ghcr.io/google/addlicense -l "apache" -c "Google LLC" .
39+
40+
- name: Commit and push license fixes
41+
# Run only on:
42+
# - Pull requests
43+
# - Not on the default branch
44+
if: >
45+
github.event_name == 'pull_request' &&
46+
github.ref_name != github.event.repository.default_branch
47+
uses: stefanzweifel/git-auto-commit-action@v5
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
with:
51+
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
52+
commit_message: "chore: add license headers"
53+
commit_user_name: addlicense
54+
commit_user_email: no-reply@addlicense.dev

0 commit comments

Comments
 (0)