projen-cdktf-hybrid-construct 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ import { javascript } from "projen";
7
+ import { JobPermission } from "projen/lib/github/workflows-model";
8
+
9
+ /**
10
+ * Approves PRs with the "auto-approve" label
11
+ */
12
+ export class AutoApprove {
13
+ constructor(project: javascript.NodeProject) {
14
+ const workflow = project.github?.addWorkflow("auto-approve");
15
+
16
+ if (!workflow) throw new Error("no workflow defined");
17
+
18
+ workflow.on({
19
+ pullRequest: {
20
+ types: ["opened", "labeled", "ready_for_review", "reopened"],
21
+ },
22
+ });
23
+
24
+ workflow.addJobs({
25
+ approve: {
26
+ runsOn: ["ubuntu-latest"],
27
+ if: "contains(github.event.pull_request.labels.*.name, 'auto-approve') && github.event.pull_request.draft == false",
28
+ steps: [
29
+ {
30
+ name: "Checkout PR",
31
+ uses: "actions/checkout@v3",
32
+ with: {
33
+ ref: "${{ github.event.pull_request.head.ref }}",
34
+ repository:
35
+ "${{ github.event.pull_request.head.repo.full_name }}",
36
+ },
37
+ },
38
+ {
39
+ name: "Auto-approve PRs by other users as team-tf-cdk",
40
+ if: "github.event.pull_request.user.login != 'team-tf-cdk'",
41
+ run: "gh pr review ${{ github.event.pull_request.number }} --approve",
42
+ env: {
43
+ GH_TOKEN: "${{ secrets.PROJEN_GITHUB_TOKEN }}",
44
+ },
45
+ },
46
+ {
47
+ name: "Auto-approve PRs by team-tf-cdk as github-actions[bot]",
48
+ if: "github.event.pull_request.user.login == 'team-tf-cdk'",
49
+ run: "gh pr review ${{ github.event.pull_request.number }} --approve",
50
+ env: {
51
+ GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}",
52
+ },
53
+ },
54
+ ],
55
+ permissions: {
56
+ contents: JobPermission.READ,
57
+ pullRequests: JobPermission.WRITE,
58
+ },
59
+ },
60
+ });
61
+ }
62
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ import { javascript } from "projen";
7
+ import { JobPermission } from "projen/lib/github/workflows-model";
8
+
9
+ /**
10
+ * Merges PRs with the "automerge" label
11
+ */
12
+ export class Automerge {
13
+ constructor(project: javascript.NodeProject) {
14
+ const workflow = project.github?.addWorkflow("automerge");
15
+
16
+ if (!workflow) throw new Error("no workflow defined");
17
+
18
+ workflow.on({
19
+ pullRequest: {
20
+ types: [
21
+ "opened",
22
+ "labeled",
23
+ "ready_for_review",
24
+ "reopened",
25
+ "synchronize",
26
+ ],
27
+ },
28
+ });
29
+
30
+ (workflow.concurrency as any) = "${{ github.workflow }}-${{ github.ref }}";
31
+
32
+ workflow.addJobs({
33
+ automerge: {
34
+ runsOn: ["ubuntu-latest"],
35
+ if: "contains(github.event.pull_request.labels.*.name, 'automerge') && github.event.pull_request.draft == false",
36
+ steps: [
37
+ {
38
+ name: "Checkout",
39
+ uses: "actions/checkout@v3",
40
+ },
41
+ {
42
+ name: "Turn on automerge for this PR",
43
+ run: "gh pr merge --auto --squash ${{ github.event.pull_request.number }}",
44
+ env: {
45
+ GH_TOKEN: "${{ secrets.PROJEN_GITHUB_TOKEN }}",
46
+ },
47
+ },
48
+ ],
49
+ permissions: {
50
+ contents: JobPermission.READ,
51
+ },
52
+ },
53
+ });
54
+ }
55
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ import { IResolver, License } from "projen";
7
+ import { TypeScriptProject } from "projen/lib/typescript";
8
+
9
+ const SPDX = "MPL-2.0";
10
+
11
+ export class CustomizedLicense extends License {
12
+ constructor(project: TypeScriptProject) {
13
+ super(project, { spdx: SPDX });
14
+
15
+ project.addFields({ license: SPDX });
16
+ }
17
+
18
+ synthesizeContent(resolver: IResolver) {
19
+ return (
20
+ "Copyright (c) 2022 HashiCorp, Inc.\n\n" +
21
+ super.synthesizeContent(resolver)
22
+ );
23
+ }
24
+ }