-
Notifications
You must be signed in to change notification settings - Fork 454
41 lines (39 loc) · 1.34 KB
/
pr-copyright.yml
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
name: "Add Copyright Headers"
on:
pull_request_target:
types:
- opened
- reopened
- synchronize
- ready_for_review
workflow_dispatch: {}
jobs:
add-copyright-headers:
runs-on: ubuntu-latest
env:
HEAD_REF: ${{ github.event.pull_request.head.ref }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Set git identity
run: |-
git config user.name "hashicorp-copywrite[bot]"
git config user.email "110428419+hashicorp-copywrite[bot]@users.noreply.github.com"
- name: Setup Copywrite tool
uses: hashicorp/setup-copywrite@867a1a2a064a0626db322392806428f7dc59cb3e # v1.1.2
- name: Add headers using Copywrite tool
run: copywrite headers
- name: Check if there are any changes
id: get_changes
run: echo "changed=$(git status --porcelain | wc -l)" >> $GITHUB_OUTPUT
- name: Push changes
if: steps.get_changes.outputs.changed != 0
run: |-
git add .
git commit -s -m "chore: add required copyright headers"
git push origin HEAD:$HEAD_REF