Skip to content

Commit 61fd266

Browse files
fix: skip checkout in CTA action before transition step (#2215)
## PR Checklist - [x] Addresses an existing open issue: fixes #2214 - [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 Upstreaming of JoshuaKGoldberg/formatly#122. Previously, the action would only check on step 2 of 3 `if` it should skip. But step 1 -checkout- requires a token that doesn't exist on fork. Now, step 1 does the `if`. No more checking out the repo unnecessarily. 🎁
1 parent 5b171ce commit 61fd266

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/blocks/blockCTATransitions.test.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,17 @@ describe("blockCTATransitions", () => {
6969
name: Transition
7070
runs-on: ubuntu-latest
7171
steps:
72-
- uses: actions/checkout@v4
72+
- id: checkout
73+
if: (github.actor == 'test-owner' || github.actor == 'renovate[bot]') && startsWith(github.head_ref, 'renovate/') && contains(github.event.pull_request.title, 'create-typescript-app')
74+
uses: actions/checkout@v4
7375
with:
7476
fetch-depth: 0
7577
ref: \${{github.event.pull_request.head.ref}}
7678
repository: \${{github.event.pull_request.head.repo.full_name}}
7779
token: \${{ secrets.ACCESS_TOKEN }}
78-
- id: check
79-
if: (github.actor == 'test-owner' || github.actor == 'renovate[bot]') && startsWith(github.head_ref, 'renovate/') && contains(github.event.pull_request.title, 'create-typescript-app')
80+
- if: steps.checkout.outcome != 'skipped'
8081
uses: ./.github/actions/transition
81-
- if: steps.check.outcome == 'skipped'
82+
- if: steps.checkout.outcome == 'skipped'
8283
run: echo 'Skipping transition mode because the PR does not appear to be an automated or owner-created update to create-typescript-app.'
8384
8485

src/blocks/blockCTATransitions.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ export const blockCTATransitions = base.createBlock({
9595
},
9696
steps: [
9797
{
98+
id: "checkout",
99+
if: `(github.actor == '${options.owner}' || github.actor == 'renovate[bot]') && startsWith(github.head_ref, 'renovate/') && contains(github.event.pull_request.title, 'create-typescript-app')`,
98100
uses: resolveUses(
99101
"actions/checkout",
100102
"v4",
@@ -109,12 +111,11 @@ export const blockCTATransitions = base.createBlock({
109111
},
110112
},
111113
{
112-
id: "check",
113-
if: `(github.actor == '${options.owner}' || github.actor == 'renovate[bot]') && startsWith(github.head_ref, 'renovate/') && contains(github.event.pull_request.title, 'create-typescript-app')`,
114+
if: "steps.checkout.outcome != 'skipped'",
114115
uses: "./.github/actions/transition",
115116
},
116117
{
117-
if: "steps.check.outcome == 'skipped'",
118+
if: "steps.checkout.outcome == 'skipped'",
118119
run: "echo 'Skipping transition mode because the PR does not appear to be an automated or owner-created update to create-typescript-app.'",
119120
},
120121
],

0 commit comments

Comments
 (0)