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 copyright headers automation #163

Merged
merged 4 commits into from Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions .copywrite.hcl
@@ -0,0 +1,13 @@
schema_version = 1

project {
license = "MPL-2.0"
copyright_year = 2020

# (OPTIONAL) A list of globs that should not have copyright/license headers.
# Supports doublestar glob patterns for more flexibility in defining which
# files or folders should be ignored
header_ignore = [
".husky/**",
]
}
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/request-provider.yml
@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

---
name: New Pre-built Provider Request
title: "New Pre-built Provider Request: PROVIDER_NAME"
Expand Down
5 changes: 5 additions & 0 deletions .github/lib/.eslintrc.js
@@ -1,3 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

module.exports = {
root: true,
env: {
Expand Down
5 changes: 5 additions & 0 deletions .github/lib/collect-changes.js
@@ -1,3 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

const fs = require("fs");
const path = require("path");

Expand Down
5 changes: 5 additions & 0 deletions .github/lib/comment-plan-output.js
@@ -1,3 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/


module.exports = ({ context, github, planOutcome, pusher, actionName, workflowName, workingDirectory, stackName }) => {
const { readFileSync } = require("fs")
Expand Down
5 changes: 5 additions & 0 deletions .github/lib/create-pr.js
@@ -1,3 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

module.exports = async ({ github, branchName, providerName, prTitle }) => {
const { GITHUB_SERVER_URL, GITHUB_REPOSITORY, GITHUB_RUN_ID } = process.env;
const url = `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}`;
Expand Down
5 changes: 5 additions & 0 deletions .github/lib/create-projen-files.js
@@ -1,3 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

module.exports = ({ providerName }) => {
const path = require("path");
const fs = require("fs");
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/add-copyright-headers.yml
@@ -0,0 +1,41 @@
name: "Add Copyright Headers"

on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
workflow_dispatch: {}

jobs:
add-copyright-headers:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
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 "team-tf-cdk"
git config user.email "github-team-tf-cdk@hashicorp.com"
- name: Setup Copywrite tool
uses: hashicorp/setup-copywrite@3ace06ad72e6ec679ea8572457b17dbc3960b8ce # v1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
- 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:${{ github.event.pull_request.head.ref }}
3 changes: 3 additions & 0 deletions .mergify.yml
@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

queue_rules:
- name: default
conditions:
Expand Down
5 changes: 5 additions & 0 deletions lib/index.ts
@@ -1,2 +1,7 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

export * from "./repository";
export * from "./secrets";
5 changes: 5 additions & 0 deletions lib/repository.ts
@@ -1,3 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

import { Construct } from "constructs";
import {
Repository,
Expand Down
5 changes: 5 additions & 0 deletions lib/secrets.ts
@@ -1,3 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

import { Construct } from "constructs";
import { Resource, TerraformVariable } from "cdktf";
import {
Expand Down
5 changes: 5 additions & 0 deletions main.ts
@@ -1,3 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

import { Construct } from "constructs";
import {
App,
Expand Down
5 changes: 5 additions & 0 deletions projenrc.template.js
@@ -1,3 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

const { CdktfProviderProject } = require("@cdktf/provider-project");
const project = new CdktfProviderProject({
useCustomGithubRunner: __CUSTOM_RUNNER__,
Expand Down