Skip to content

Commit bb0f8cf

Browse files
authored
ci: improve header validation workflow (#19)
Signed-off-by: Pavel Polyakov <djeredian@gmail.com>
1 parent 118fb2a commit bb0f8cf

3 files changed

Lines changed: 56 additions & 48 deletions

File tree

.github/workflows/automation_fix_copyright.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/lint_copyright.yml

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,21 @@ concurrency:
55
cancel-in-progress: true
66

77
on:
8-
push:
9-
branches:
10-
- main
11-
pull_request_target:
8+
pull_request:
9+
types:
10+
- opened
11+
- reopened
12+
- synchronize
13+
- ready_for_review
1214

1315
permissions:
1416
contents: write
1517
pull-requests: write
1618

1719
jobs:
18-
licenses:
20+
# validate file headers for all conributers except org members
21+
validate_licenses:
22+
if: ${{ !contains('["Jeredian","Elkin-Vasily","GudwinTheGreat"]', github.actor) }}
1923
runs-on: ubuntu-latest
2024
steps:
2125
- name: Checkout
@@ -33,3 +37,49 @@ jobs:
3337
id: lint_file_headers
3438
with:
3539
token: ${{ steps.generate_token.outputs.token }}
40+
# fix file headers for org members only
41+
fix-headers:
42+
if: contains('["Jeredian","Elkin-Vasily","GudwinTheGreat"]', github.actor)
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Generate token
46+
uses: tibdex/github-app-token@v2.1.0
47+
id: generate_token
48+
with:
49+
app_id: ${{ secrets.APP_ID }}
50+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
51+
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
with:
55+
token: ${{ steps.generate_token.outputs.token }}
56+
57+
- name: Validate License Header
58+
uses: apache/skywalking-eyes@v0.5.0
59+
id: lint_file_headers
60+
with:
61+
token: ${{ steps.generate_token.outputs.token }}
62+
mode: fix
63+
64+
- name: Apply Changes
65+
uses: stefanzweifel/git-auto-commit-action@v5.0.0
66+
id: auto-commit-action
67+
with:
68+
github_token: ${{ steps.generate_token.outputs.token }}
69+
commit_options: '--signoff'
70+
commit_user_name: Print Maker Lab Bot
71+
message: 'refactor: automatic updating of file headers'
72+
73+
- name: Add new comment
74+
if: steps.auto-commit-action.outputs.changes_detected == 'true'
75+
uses: peter-evans/create-or-update-comment@v4.0.0
76+
with:
77+
issue-number: ${{ github.event.pull_request.number }}
78+
comment-author: 'Print Maker Lab [bot]'
79+
token: ${{ steps.generate_token.outputs.token }}
80+
body: |
81+
👋 Hey there
82+
Print Maker Lab Bot, just updated your files with the correct license headers.
83+
reactions: |
84+
heart
85+
hooray

.github/workflows/pull_request_check_title.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
if: ${{ always() }}
5858
with:
5959
header: ${{ github.job }}
60+
recreate: true
6061
message: |
6162
👋 Hey there and thank you for opening this pull request!
6263
We require pull request titles to follow the [Conventional Commits specification](https://github.com/PrintMakerLab/.github/blob/main/CONTRIBUTING.md#commit)

0 commit comments

Comments
 (0)