code-foundry 0.24.1 → 0.25.0

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.
@@ -390,7 +390,7 @@ done
390
390
  standard_workflow() {
391
391
  case "$1" in
392
392
  ci.yml|codeql.yml|draft-pr.yml|release-pr.yml|release.yml|security.yml|test.yml) return 0 ;;
393
- reusable-draft-pr.yml|reusable-release-pr.yml) return 0 ;;
393
+ *_self-ci.yml) return 0 ;;
394
394
  *) return 1 ;;
395
395
  esac
396
396
  }
@@ -417,6 +417,13 @@ fi
417
417
 
418
418
  for file in "${files[@]}"; do
419
419
  template_file="$template_root/$file"
420
+ case "$file" in
421
+ .github/workflows/*.yml)
422
+ workflow_name="${file##*/}"
423
+ workflow_name="${workflow_name%.yml}"
424
+ template_file="$template_root/.github/workflows/${workflow_name}_self-ci.yml"
425
+ ;;
426
+ esac
420
427
  # npm renames .gitignore to .npmignore when installing a package. Treat the
421
428
  # renamed file as the same template asset so packaged initialization works.
422
429
  if [ "$file" = .gitignore ] && [ ! -f "$template_file" ] && [ -f "$template_root/.npmignore" ]; then
@@ -489,7 +496,7 @@ fi
489
496
  [ -n "$source_runtime_ref" ] || source_runtime_ref="$runtime_ref"
490
497
  for file in .github/workflows/ci.yml .github/workflows/test.yml .github/workflows/security.yml .github/workflows/codeql.yml .github/workflows/draft-pr.yml .github/workflows/release-pr.yml .github/workflows/release.yml; do
491
498
  [ -f "$file" ] || continue
492
- if grep -qF "$source_runtime_repository@" "$file" || grep -q 'runtime-ref:' "$file"; then
499
+ if grep -qF "$source_runtime_repository@" "$file" || grep -q 'runtime-ref:' "$file" || grep -qF 'uses: ./.github/workflows/' "$file"; then
493
500
  changed=$((changed + 1))
494
501
  if [ "$mode" = "check" ]; then
495
502
  printf 'Would render runtime repository in %s\n' "$file"
@@ -506,6 +513,7 @@ for file in .github/workflows/ci.yml .github/workflows/test.yml .github/workflow
506
513
  rendered_workflow="$(mktemp)"
507
514
  sed -E \
508
515
  -e "s#${source_runtime_repository}@[^[:space:]]+#${runtime_repository}@${runtime_ref}#g" \
516
+ -e "s#uses: \.\/.github/workflows/([^[:space:]]+)#uses: ${runtime_repository}/.github/workflows/\\1@${runtime_ref}#g" \
509
517
  -e "s#runtime-ref: [^[:space:]]+#runtime-ref: ${runtime_ref}#g" \
510
518
  -e "s#^ runner: [^[:space:]]+# runner: ${runner_value}#" \
511
519
  -e "s#^ unit-runner: [^[:space:]]+# unit-runner: ${unit_runner}#" \
@@ -1,21 +1,184 @@
1
- name: CI
1
+ name: Code Foundry CI
2
2
 
3
3
  on:
4
- push:
5
- branches: [main, staging]
6
- pull_request:
7
- branches: [staging]
8
- workflow_dispatch:
4
+ workflow_call:
5
+ inputs:
6
+ runtime-repository:
7
+ description: Repository containing the Code Foundry runtime.
8
+ required: false
9
+ type: string
10
+ default: 0xPlayerOne/code-foundry
11
+ runtime-ref:
12
+ description: Code Foundry runtime tag or ref.
13
+ required: false
14
+ type: string
15
+ default: v0.20.2
16
+ runner:
17
+ description: Runner used by CI jobs.
18
+ required: false
19
+ type: string
20
+ default: ubuntu-latest
9
21
 
10
22
  permissions:
11
23
  contents: read
12
24
 
25
+ env:
26
+ TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
27
+ TURBO_TEAM: ${{ vars.TURBO_TEAM }}
28
+ REPO_FOUNDRY_PROFILE: ${{ vars.REPO_FOUNDRY_PROFILE }}
29
+ REPO_FOUNDRY_LANGUAGES: ${{ vars.REPO_FOUNDRY_LANGUAGES }}
30
+ REPO_FOUNDRY_FEATURES: ${{ vars.REPO_FOUNDRY_FEATURES }}
31
+ REPO_FOUNDRY_PACKAGE_MANAGER: ${{ vars.REPO_FOUNDRY_PACKAGE_MANAGER }}
32
+ REPO_FOUNDRY_RUNNER: ${{ vars.REPO_FOUNDRY_RUNNER }}
33
+ REPO_FOUNDRY_CACHE_PACKAGES: ${{ vars.REPO_FOUNDRY_CACHE_PACKAGES || 'auto' }}
34
+ REPO_FOUNDRY_CACHE_BUILD: ${{ vars.REPO_FOUNDRY_CACHE_BUILD || 'auto' }}
35
+ REPO_FOUNDRY_BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before || '' }}
36
+
37
+ concurrency:
38
+ group: ${{ github.workflow }}-${{ github.event.pull_request.head.repo.full_name || github.repository }}-${{ github.event.pull_request.head.ref || github.ref_name }}
39
+ cancel-in-progress: true
40
+
13
41
  jobs:
14
- ci:
15
- name: CI
16
- uses: 0xPlayerOne/code-foundry/.github/workflows/reusable-ci.yml@v0.22.0
17
- with:
18
- runtime-repository: 0xPlayerOne/code-foundry
19
- runtime-ref: v0.22.0
20
- runner: ubuntu-latest
21
- secrets: inherit
42
+ format:
43
+ name: Format
44
+ runs-on: ${{ inputs.runner }}
45
+ steps:
46
+ - name: Checkout
47
+ uses: actions/checkout@v7
48
+ - name: Runtime
49
+ uses: actions/checkout@v7
50
+ with:
51
+ repository: ${{ inputs.runtime-repository }}
52
+ ref: ${{ inputs.runtime-ref }}
53
+ path: .code-foundry
54
+ sparse-checkout: |
55
+ .github/actions
56
+ .github/scripts
57
+ - name: Install runtime
58
+ run: |
59
+ mkdir -p .github/actions .github/scripts
60
+ cp -R .code-foundry/.github/actions/. .github/actions/
61
+ cp -R .code-foundry/.github/scripts/. .github/scripts/
62
+ - name: Detect
63
+ id: applicability
64
+ run: bash .github/scripts/ci.sh should_run format >> "$GITHUB_OUTPUT"
65
+ - name: Fast path
66
+ if: steps.applicability.outputs.applicable == 'true'
67
+ run: bash .github/scripts/format-fast-path.sh
68
+ - name: Setup
69
+ if: steps.applicability.outputs.applicable == 'true'
70
+ uses: ./.github/actions/setup
71
+ with:
72
+ install: 'false'
73
+ cache-format: 'true'
74
+ cache-lint: 'false'
75
+ cache-build: 'false'
76
+ task: format
77
+ task-javascript: 'true'
78
+ task-python: 'false'
79
+ task-rust: 'false'
80
+ - name: Format
81
+ if: steps.applicability.outputs.applicable == 'true'
82
+ run: bash .github/scripts/ci.sh format
83
+
84
+ lint:
85
+ name: Lint
86
+ runs-on: ${{ inputs.runner }}
87
+ steps:
88
+ - name: Checkout
89
+ uses: actions/checkout@v7
90
+ - name: Runtime
91
+ uses: actions/checkout@v7
92
+ with:
93
+ repository: ${{ inputs.runtime-repository }}
94
+ ref: ${{ inputs.runtime-ref }}
95
+ path: .code-foundry
96
+ sparse-checkout: |
97
+ .github/actions
98
+ .github/scripts
99
+ - name: Install runtime
100
+ run: |
101
+ mkdir -p .github/actions .github/scripts
102
+ cp -R .code-foundry/.github/actions/. .github/actions/
103
+ cp -R .code-foundry/.github/scripts/. .github/scripts/
104
+ - name: Detect
105
+ id: applicability
106
+ run: bash .github/scripts/ci.sh should_run lint >> "$GITHUB_OUTPUT"
107
+ - name: Setup
108
+ if: steps.applicability.outputs.applicable == 'true'
109
+ uses: ./.github/actions/setup
110
+ with:
111
+ install: 'true'
112
+ cache-lint: 'true'
113
+ task: lint
114
+ - name: Lint
115
+ if: steps.applicability.outputs.applicable == 'true'
116
+ run: bash .github/scripts/ci.sh lint
117
+
118
+ type-check:
119
+ name: Type-Check
120
+ runs-on: ${{ inputs.runner }}
121
+ steps:
122
+ - name: Checkout
123
+ uses: actions/checkout@v7
124
+ - name: Runtime
125
+ uses: actions/checkout@v7
126
+ with:
127
+ repository: ${{ inputs.runtime-repository }}
128
+ ref: ${{ inputs.runtime-ref }}
129
+ path: .code-foundry
130
+ sparse-checkout: |
131
+ .github/actions
132
+ .github/scripts
133
+ - name: Install runtime
134
+ run: |
135
+ mkdir -p .github/actions .github/scripts
136
+ cp -R .code-foundry/.github/actions/. .github/actions/
137
+ cp -R .code-foundry/.github/scripts/. .github/scripts/
138
+ - name: Detect
139
+ id: applicability
140
+ run: bash .github/scripts/ci.sh should_run type_check >> "$GITHUB_OUTPUT"
141
+ - name: Setup
142
+ if: steps.applicability.outputs.applicable == 'true'
143
+ uses: ./.github/actions/setup
144
+ with:
145
+ install: 'true'
146
+ cache-build: 'true'
147
+ task: type_check
148
+ - name: Type-Check
149
+ if: steps.applicability.outputs.applicable == 'true'
150
+ run: bash .github/scripts/ci.sh type_check
151
+
152
+ build:
153
+ name: Build
154
+ runs-on: ${{ inputs.runner }}
155
+ steps:
156
+ - name: Checkout
157
+ uses: actions/checkout@v7
158
+ - name: Runtime
159
+ uses: actions/checkout@v7
160
+ with:
161
+ repository: ${{ inputs.runtime-repository }}
162
+ ref: ${{ inputs.runtime-ref }}
163
+ path: .code-foundry
164
+ sparse-checkout: |
165
+ .github/actions
166
+ .github/scripts
167
+ - name: Install runtime
168
+ run: |
169
+ mkdir -p .github/actions .github/scripts
170
+ cp -R .code-foundry/.github/actions/. .github/actions/
171
+ cp -R .code-foundry/.github/scripts/. .github/scripts/
172
+ - name: Detect
173
+ id: applicability
174
+ run: bash .github/scripts/ci.sh should_run build >> "$GITHUB_OUTPUT"
175
+ - name: Setup
176
+ if: steps.applicability.outputs.applicable == 'true'
177
+ uses: ./.github/actions/setup
178
+ with:
179
+ install: 'true'
180
+ cache-build: 'true'
181
+ task: build
182
+ - name: Build
183
+ if: steps.applicability.outputs.applicable == 'true'
184
+ run: bash .github/scripts/ci.sh build
@@ -0,0 +1,21 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, staging]
6
+ pull_request:
7
+ branches: [staging]
8
+ workflow_dispatch:
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ ci:
15
+ name: CI
16
+ uses: ./.github/workflows/ci.yml
17
+ with:
18
+ runtime-repository: 0xPlayerOne/code-foundry
19
+ runtime-ref: v0.22.0
20
+ runner: ubuntu-latest
21
+ secrets: inherit
@@ -1,13 +1,23 @@
1
- name: CodeQL
1
+ name: Code Foundry CodeQL
2
2
 
3
3
  on:
4
- push:
5
- branches: [main, staging]
6
- pull_request:
7
- branches: [staging]
8
- schedule:
9
- - cron: '31 6 * * 1'
10
- workflow_dispatch:
4
+ workflow_call:
5
+ inputs:
6
+ runtime-repository:
7
+ description: Repository containing the Code Foundry runtime.
8
+ required: false
9
+ type: string
10
+ default: 0xPlayerOne/code-foundry
11
+ runtime-ref:
12
+ description: Code Foundry runtime tag or ref.
13
+ required: false
14
+ type: string
15
+ default: v0.20.2
16
+ runner:
17
+ description: Runner used by CodeQL jobs.
18
+ required: false
19
+ type: string
20
+ default: ubuntu-latest
11
21
 
12
22
  permissions:
13
23
  actions: read
@@ -15,12 +25,222 @@ permissions:
15
25
  packages: read
16
26
  security-events: write
17
27
 
28
+ env:
29
+ REPO_FOUNDRY_PROFILE: ${{ vars.REPO_FOUNDRY_PROFILE }}
30
+ REPO_FOUNDRY_LANGUAGES: ${{ vars.REPO_FOUNDRY_LANGUAGES }}
31
+ REPO_FOUNDRY_FEATURES: ${{ vars.REPO_FOUNDRY_FEATURES }}
32
+
33
+ concurrency:
34
+ group: ${{ github.workflow }}-${{ github.event.pull_request.head.repo.full_name || github.repository }}-${{ github.event.pull_request.head.ref || github.ref_name }}
35
+ cancel-in-progress: true
36
+
18
37
  jobs:
19
- codeql:
20
- name: CodeQL
21
- uses: 0xPlayerOne/code-foundry/.github/workflows/reusable-codeql.yml@v0.22.0
22
- with:
23
- runtime-repository: 0xPlayerOne/code-foundry
24
- runtime-ref: v0.22.0
25
- runner: ubuntu-latest
26
- secrets: inherit
38
+ detect:
39
+ name: Detect
40
+ runs-on: ${{ inputs.runner }}
41
+ timeout-minutes: 10
42
+ outputs:
43
+ languages: ${{ steps.languages.outputs.languages }}
44
+ code_security: ${{ steps.security.outputs.status }}
45
+ actions_available: ${{ steps.languages.outputs.actions_available }}
46
+ actions_changed: ${{ steps.languages.outputs.actions_changed }}
47
+ actions_build_mode: ${{ steps.languages.outputs.actions_build_mode }}
48
+ javascript_available: ${{ steps.languages.outputs.javascript_available }}
49
+ javascript_changed: ${{ steps.languages.outputs.javascript_changed }}
50
+ javascript_build_mode: ${{ steps.languages.outputs.javascript_build_mode }}
51
+ python_available: ${{ steps.languages.outputs.python_available }}
52
+ python_changed: ${{ steps.languages.outputs.python_changed }}
53
+ python_build_mode: ${{ steps.languages.outputs.python_build_mode }}
54
+ rust_available: ${{ steps.languages.outputs.rust_available }}
55
+ rust_changed: ${{ steps.languages.outputs.rust_changed }}
56
+ rust_build_mode: ${{ steps.languages.outputs.rust_build_mode }}
57
+ steps:
58
+ - name: Detect Code Security
59
+ id: security
60
+ env:
61
+ GH_TOKEN: ${{ github.token }}
62
+ run: |
63
+ status="disabled"
64
+ if [ "${{ github.event.repository.private }}" != "true" ]; then
65
+ status="enabled"
66
+ else
67
+ status="$(gh api "repos/${GITHUB_REPOSITORY}" --jq '.security_and_analysis.code_security.status // "disabled"' 2>/dev/null || printf 'disabled')"
68
+ fi
69
+ printf 'status=%s\n' "$status" >> "$GITHUB_OUTPUT"
70
+ - name: Checkout
71
+ if: ${{ !github.event.repository.private || steps.security.outputs.status == 'enabled' }}
72
+ uses: actions/checkout@v7
73
+ with:
74
+ fetch-depth: 2
75
+ filter: blob:none
76
+ sparse-checkout: |
77
+ .github
78
+ .mise.toml
79
+ mise.lock
80
+ package.json
81
+ bun.lock
82
+ bun.lockb
83
+ pnpm-lock.yaml
84
+ yarn.lock
85
+ package-lock.json
86
+ sparse-checkout-cone-mode: false
87
+ - name: Runtime
88
+ if: ${{ !github.event.repository.private || steps.security.outputs.status == 'enabled' }}
89
+ uses: actions/checkout@v7
90
+ with:
91
+ repository: ${{ inputs.runtime-repository }}
92
+ ref: ${{ inputs.runtime-ref }}
93
+ path: .code-foundry
94
+ sparse-checkout: |
95
+ .github/actions
96
+ .github/scripts
97
+ - name: Install runtime
98
+ if: ${{ !github.event.repository.private || steps.security.outputs.status == 'enabled' }}
99
+ run: |
100
+ mkdir -p .github/actions .github/scripts
101
+ cp -R .code-foundry/.github/actions/. .github/actions/
102
+ cp -R .code-foundry/.github/scripts/. .github/scripts/
103
+ - id: languages
104
+ name: Detect languages
105
+ env:
106
+ CODEQL_BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
107
+ REPO_FOUNDRY_CODE_SECURITY: ${{ steps.security.outputs.status }}
108
+ REPO_FOUNDRY_PRIVATE: ${{ github.event.repository.private }}
109
+ run: |
110
+ if [ "$REPO_FOUNDRY_PRIVATE" = "true" ] && [ "$REPO_FOUNDRY_CODE_SECURITY" != "enabled" ]; then
111
+ echo 'languages=[]' >> "$GITHUB_OUTPUT"
112
+ else
113
+ bash .github/scripts/codeql-languages.sh
114
+ fi
115
+
116
+ analyze-actions:
117
+ name: Analyze (Actions)
118
+ needs: detect
119
+ if: >-
120
+ ( !github.event.repository.private || needs.detect.outputs.code_security == 'enabled' ) &&
121
+ needs.detect.outputs.actions_available == 'true' &&
122
+ needs.detect.outputs.actions_changed == 'true'
123
+ runs-on: ${{ inputs.runner }}
124
+ timeout-minutes: 30
125
+ steps:
126
+ - name: Checkout
127
+ uses: actions/checkout@v7
128
+ - name: Runtime
129
+ uses: actions/checkout@v7
130
+ with:
131
+ repository: ${{ inputs.runtime-repository }}
132
+ ref: ${{ inputs.runtime-ref }}
133
+ path: .code-foundry
134
+ sparse-checkout: |
135
+ .github/actions
136
+ .github/scripts
137
+ - name: Install runtime
138
+ run: |
139
+ mkdir -p .github/actions .github/scripts
140
+ cp -R .code-foundry/.github/actions/. .github/actions/
141
+ cp -R .code-foundry/.github/scripts/. .github/scripts/
142
+ - name: Analyze
143
+ uses: ./.github/actions/codeql
144
+ with:
145
+ language: actions
146
+ build-mode: ${{ needs.detect.outputs.actions_build_mode }}
147
+ category: /language:actions
148
+
149
+ analyze-typescript:
150
+ name: Analyze (TypeScript)
151
+ needs: detect
152
+ if: >-
153
+ ( !github.event.repository.private || needs.detect.outputs.code_security == 'enabled' ) &&
154
+ needs.detect.outputs.javascript_available == 'true' &&
155
+ needs.detect.outputs.javascript_changed == 'true'
156
+ runs-on: ${{ inputs.runner }}
157
+ timeout-minutes: 30
158
+ steps:
159
+ - name: Checkout
160
+ uses: actions/checkout@v7
161
+ - name: Runtime
162
+ uses: actions/checkout@v7
163
+ with:
164
+ repository: ${{ inputs.runtime-repository }}
165
+ ref: ${{ inputs.runtime-ref }}
166
+ path: .code-foundry
167
+ sparse-checkout: |
168
+ .github/actions
169
+ .github/scripts
170
+ - name: Install runtime
171
+ run: |
172
+ mkdir -p .github/actions .github/scripts
173
+ cp -R .code-foundry/.github/actions/. .github/actions/
174
+ cp -R .code-foundry/.github/scripts/. .github/scripts/
175
+ - name: Analyze
176
+ uses: ./.github/actions/codeql
177
+ with:
178
+ language: javascript-typescript
179
+ build-mode: ${{ needs.detect.outputs.javascript_build_mode }}
180
+ category: /language:javascript-typescript
181
+
182
+ analyze-python:
183
+ name: Analyze (Python)
184
+ needs: detect
185
+ if: >-
186
+ ( !github.event.repository.private || needs.detect.outputs.code_security == 'enabled' ) &&
187
+ needs.detect.outputs.python_available == 'true' &&
188
+ needs.detect.outputs.python_changed == 'true'
189
+ runs-on: ${{ inputs.runner }}
190
+ timeout-minutes: 30
191
+ steps:
192
+ - name: Checkout
193
+ uses: actions/checkout@v7
194
+ - name: Runtime
195
+ uses: actions/checkout@v7
196
+ with:
197
+ repository: ${{ inputs.runtime-repository }}
198
+ ref: ${{ inputs.runtime-ref }}
199
+ path: .code-foundry
200
+ sparse-checkout: |
201
+ .github/actions
202
+ .github/scripts
203
+ - name: Install runtime
204
+ run: |
205
+ mkdir -p .github/actions .github/scripts
206
+ cp -R .code-foundry/.github/actions/. .github/actions/
207
+ cp -R .code-foundry/.github/scripts/. .github/scripts/
208
+ - name: Analyze
209
+ uses: ./.github/actions/codeql
210
+ with:
211
+ language: python
212
+ build-mode: ${{ needs.detect.outputs.python_build_mode }}
213
+ category: /language:python
214
+
215
+ analyze-rust:
216
+ name: Analyze (Rust)
217
+ needs: detect
218
+ if: >-
219
+ ( !github.event.repository.private || needs.detect.outputs.code_security == 'enabled' ) &&
220
+ needs.detect.outputs.rust_available == 'true' &&
221
+ needs.detect.outputs.rust_changed == 'true'
222
+ runs-on: ${{ inputs.runner }}
223
+ timeout-minutes: 30
224
+ steps:
225
+ - name: Checkout
226
+ uses: actions/checkout@v7
227
+ - name: Runtime
228
+ uses: actions/checkout@v7
229
+ with:
230
+ repository: ${{ inputs.runtime-repository }}
231
+ ref: ${{ inputs.runtime-ref }}
232
+ path: .code-foundry
233
+ sparse-checkout: |
234
+ .github/actions
235
+ .github/scripts
236
+ - name: Install runtime
237
+ run: |
238
+ mkdir -p .github/actions .github/scripts
239
+ cp -R .code-foundry/.github/actions/. .github/actions/
240
+ cp -R .code-foundry/.github/scripts/. .github/scripts/
241
+ - name: Analyze
242
+ uses: ./.github/actions/codeql
243
+ with:
244
+ language: rust
245
+ build-mode: ${{ needs.detect.outputs.rust_build_mode }}
246
+ category: /language:rust
@@ -0,0 +1,26 @@
1
+ name: CodeQL
2
+
3
+ on:
4
+ push:
5
+ branches: [main, staging]
6
+ pull_request:
7
+ branches: [staging]
8
+ schedule:
9
+ - cron: '31 6 * * 1'
10
+ workflow_dispatch:
11
+
12
+ permissions:
13
+ actions: read
14
+ contents: read
15
+ packages: read
16
+ security-events: write
17
+
18
+ jobs:
19
+ codeql:
20
+ name: CodeQL
21
+ uses: ./.github/workflows/codeql.yml
22
+ with:
23
+ runtime-repository: 0xPlayerOne/code-foundry
24
+ runtime-ref: v0.22.0
25
+ runner: ubuntu-latest
26
+ secrets: inherit
@@ -1,24 +1,57 @@
1
- name: Draft PR
1
+ name: Code Foundry Draft PR
2
2
 
3
3
  on:
4
- push:
5
- branches:
6
- - 'feat/*'
7
- - 'fix/*'
8
- - 'chore/*'
9
- - 'refactor/*'
10
- - 'docs/*'
11
- - 'style/*'
12
- - 'test/*'
4
+ workflow_call:
5
+ inputs:
6
+ runner:
7
+ description: Runner used to create the draft PR.
8
+ required: false
9
+ type: string
10
+ default: ubuntu-slim
13
11
 
14
12
  permissions:
15
13
  contents: read
16
14
  pull-requests: write
17
15
 
16
+ env:
17
+ GH_TOKEN: ${{ github.token }}
18
+
18
19
  jobs:
19
- draft-pr:
20
- name: Draft PR
21
- uses: 0xPlayerOne/code-foundry/.github/workflows/reusable-draft-pr.yml@v0.22.0
22
- with:
23
- runner: ubuntu-slim
24
- secrets: inherit
20
+ create-draft-pr:
21
+ name: Create
22
+ runs-on: ${{ inputs.runner }}
23
+ timeout-minutes: 10
24
+ concurrency:
25
+ group: ${{ github.workflow }}-${{ github.ref }}
26
+ cancel-in-progress: true
27
+ steps:
28
+ - name: Check
29
+ id: check-pr
30
+ run: |
31
+ BRANCH="${{ github.ref_name }}"
32
+ EXISTING=$(gh pr list --limit 1 --base staging --head "$BRANCH" --state open --json number,title 2>/dev/null | jq 'length')
33
+ echo "existing=$EXISTING" >> "$GITHUB_OUTPUT"
34
+
35
+ - name: Create
36
+ if: steps.check-pr.outputs.existing == '0'
37
+ run: |
38
+ BRANCH="${{ github.ref_name }}"
39
+ gh pr create \
40
+ --base staging \
41
+ --head "$BRANCH" \
42
+ --draft \
43
+ --title "[WIP] $BRANCH" \
44
+ --body "Draft PR created automatically by CI.
45
+
46
+ This PR is a draft and should not be merged until CI passes and a reviewer (or the Daily Review agent) marks it ready.
47
+
48
+ **CI Status:** Pending — this workflow triggered on push to \`$BRANCH\`."
49
+
50
+ - name: Mark ready
51
+ if: steps.check-pr.outputs.existing == '0'
52
+ run: |
53
+ BRANCH="${{ github.ref_name }}"
54
+ PR_NUMBER=$(gh pr list --limit 1 --base staging --head "$BRANCH" --state open --json number 2>/dev/null | jq '.[0].number')
55
+ if [ -n "$PR_NUMBER" ]; then
56
+ gh pr ready "$PR_NUMBER"
57
+ fi
@@ -0,0 +1,24 @@
1
+ name: Draft PR
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - 'feat/*'
7
+ - 'fix/*'
8
+ - 'chore/*'
9
+ - 'refactor/*'
10
+ - 'docs/*'
11
+ - 'style/*'
12
+ - 'test/*'
13
+
14
+ permissions:
15
+ contents: read
16
+ pull-requests: write
17
+
18
+ jobs:
19
+ draft-pr:
20
+ name: Draft PR
21
+ uses: ./.github/workflows/draft-pr.yml
22
+ with:
23
+ runner: ubuntu-slim
24
+ secrets: inherit