Backport of Add license-checker action that fails when any backported file contains BUSL header into release/1.16.x (#18489)

Add license-checker action that fails when any backported file contains BUSL header (#18485)

* Add license-checker action that fails when any backported file contains BUSL header

* Quote echoed variable to retain line breaks

* Add ticket to reference for more details

Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>
This commit is contained in:
hc-github-team-consul-core 2023-08-16 15:24:57 -05:00 committed by GitHub
parent 3ee89050e7
commit d69a061a77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 0 deletions

16
.github/scripts/license_checker.sh vendored Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
busl_files=$(grep -r 'SPDX-License-Identifier: BUSL' --exclude=./.github/scripts/license_checker.sh .)
# If we do not find a file in .changelog/, we fail the check
if [ -n "$busl_files" ]; then
echo "Found BUSL occurrences in the PR branch! (See NET-5258 for details)"
echo -n "$busl_files"
exit 1
else
echo "Did not find any occurrences of BUSL in the PR branch"
exit 0
fi

27
.github/workflows/license-checker.yml vendored Normal file
View File

@ -0,0 +1,27 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
# This workflow checks that the BUSL license is not mentioned anywhere in
# a PR targeting a release that should maintain the MPL-2.0 license.
name: License Checker
on:
pull_request:
types: [opened]
branches:
- release/1.14.*
- release/1.15.*
- release/1.16.*
jobs:
# checks that the diff does not contain any reference to
# the BUSL license and thus retains the MPL-2.0 license
license-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 # by default the checkout action doesn't checkout all branches
- name: Check for BUSL text in diff
run: ./.github/scripts/license_checker.sh