Skip to content

Commit 84f2205

Browse files
feat: draft PR in blockCTATransitions when package.json engines is changed (#2229)
## PR Checklist - [x] Addresses an existing open issue: fixes #2185 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Goes with the suggested strategy in #2185 (comment) of, once per PR that changes `engines`: 1. Switching the PR to draft 2. Posting a comment explaining that it changes engines 🎁
1 parent 36cbb8a commit 84f2205

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

src/blocks/blockCTATransitions.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ describe("blockCTATransitions", () => {
3232
"transition": {
3333
"action.yml": "description: Runs create-typescript-app in transition mode
3434
35+
inputs:
36+
token:
37+
description: GitHub personal access token with repo, workflow, and read:org permissions.
38+
required: true
39+
3540
name: Transition
3641
3742
runs:
@@ -59,6 +64,19 @@ describe("blockCTATransitions", () => {
5964
— _The Friendly Bingo Bot_ 💝
6065
6166
> ℹ️ These automatic commits keep your repository up-to-date with new versions of [create-typescript-app](https://github.com/JoshuaKGoldberg/create-typescript-app). If you want to opt out, delete your \`.github/workflows/cta-transitions.yml\` file.
67+
- id: package-change
68+
uses: JoshuaKGoldberg/[email protected]
69+
with:
70+
properties: engines
71+
- if: steps.package-change.outputs.changed == 'true'
72+
uses: JoshuaKGoldberg/[email protected]
73+
with:
74+
github-token: \${{ inputs.token }}
75+
message: |-
76+
🤖 Beep boop! This PR changes the \`engines\` field in \`package.json\`. That might be a breaking change. It's been set to a draft so that it doesn't automatically merge. Go ahead and un-draft the PR if the change is ready for release.
77+
78+
Cheers!
79+
— _The Friendly Bingo Bot_ 💝
6280
using: composite
6381
",
6482
},
@@ -79,6 +97,8 @@ describe("blockCTATransitions", () => {
7997
token: \${{ secrets.ACCESS_TOKEN }}
8098
- if: steps.checkout.outcome != 'skipped'
8199
uses: ./.github/actions/transition
100+
with:
101+
token: \${{ secrets.ACCESS_TOKEN }}
82102
- if: steps.checkout.outcome == 'skipped'
83103
run: echo 'Skipping transition mode because the PR does not appear to be an automated or owner-created update to create-typescript-app.'
84104

src/blocks/blockCTATransitions.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ export const blockCTATransitions = base.createBlock({
3030
transition: {
3131
"action.yml": formatYaml({
3232
description: "Runs create-typescript-app in transition mode",
33+
inputs: {
34+
token: {
35+
description:
36+
"GitHub personal access token with repo, workflow, and read:org permissions.",
37+
required: true,
38+
},
39+
},
3340
name: "Transition",
3441
runs: {
3542
steps: [
@@ -75,6 +82,34 @@ export const blockCTATransitions = base.createBlock({
7582
].join("\n"),
7683
},
7784
},
85+
{
86+
id: "package-change",
87+
uses: resolveUses(
88+
"JoshuaKGoldberg/package-change-detector-action",
89+
"0.1.0",
90+
options.workflowsVersions,
91+
),
92+
with: {
93+
properties: "engines",
94+
},
95+
},
96+
{
97+
if: `steps.package-change.outputs.changed == 'true'`,
98+
uses: resolveUses(
99+
"JoshuaKGoldberg/draft-pull-request-once-action",
100+
"0.0.1",
101+
options.workflowsVersions,
102+
),
103+
with: {
104+
"github-token": "${{ inputs.token }}",
105+
message: [
106+
"🤖 Beep boop! This PR changes the `engines` field in `package.json`. That might be a breaking change. It's been set to a draft so that it doesn't automatically merge. Go ahead and un-draft the PR if the change is ready for release.",
107+
"",
108+
"Cheers!",
109+
" — _The Friendly Bingo Bot_ 💝",
110+
].join("\n"),
111+
},
112+
},
78113
],
79114
using: "composite",
80115
},
@@ -113,6 +148,9 @@ export const blockCTATransitions = base.createBlock({
113148
{
114149
if: "steps.checkout.outcome != 'skipped'",
115150
uses: "./.github/actions/transition",
151+
with: {
152+
token: "${{ secrets.ACCESS_TOKEN }}",
153+
},
116154
},
117155
{
118156
if: "steps.checkout.outcome == 'skipped'",

0 commit comments

Comments
 (0)