Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add workflow to automatically add copyright headers when they are missing #105

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/add-copyright-headers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
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 "[COMPLIANCE] Add required copyright headers"
git push origin HEAD:$HEAD_REF
Loading