pipecraft 0.0.0-releaseit

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.
Files changed (176) hide show
  1. package/.claude/settings.local.json +35 -0
  2. package/.github/actions/calculate-version/action.yml +106 -0
  3. package/.github/actions/create-pr/action.yml +122 -0
  4. package/.github/actions/create-release/action.yml +74 -0
  5. package/.github/actions/create-tag/action.yml +94 -0
  6. package/.github/actions/detect-changes/action.yml +62 -0
  7. package/.github/actions/manage-branch/action.yml +113 -0
  8. package/.github/actions/promote-branch/action.yml +352 -0
  9. package/.github/example/workflows/job.analyze.code.yml +26 -0
  10. package/.github/example/workflows/job.analyze.docker.yml +32 -0
  11. package/.github/example/workflows/job.app.api.deploy.yml +127 -0
  12. package/.github/example/workflows/job.app.api.test.yml +102 -0
  13. package/.github/example/workflows/job.app.docs.deploy.yml +40 -0
  14. package/.github/example/workflows/job.app.docs.test.yml +50 -0
  15. package/.github/example/workflows/job.app.web.deploy.yml +96 -0
  16. package/.github/example/workflows/job.app.web.test.yml +49 -0
  17. package/.github/example/workflows/job.changes.yml +82 -0
  18. package/.github/example/workflows/job.create-pr.yml +96 -0
  19. package/.github/example/workflows/job.env-check.yml +43 -0
  20. package/.github/example/workflows/job.fast-forward.yml +103 -0
  21. package/.github/example/workflows/job.lint.yml +64 -0
  22. package/.github/example/workflows/job.pr-name.yml +70 -0
  23. package/.github/example/workflows/job.pr-squash-name.yml +27 -0
  24. package/.github/example/workflows/job.tag.yml +38 -0
  25. package/.github/example/workflows/job.version.yml +99 -0
  26. package/.github/example/workflows/lib.plugin-base.publish.yml +59 -0
  27. package/.github/example/workflows/pipe.yml +178 -0
  28. package/.github/example/workflows/scripts/fastforward.sh +51 -0
  29. package/.github/example/workflows/scripts/pipe-cleaner.sh +70 -0
  30. package/.github/scripts/fastforward.sh +51 -0
  31. package/.github/scripts/pipe-cleaner.sh +70 -0
  32. package/.github/workflows/pipeline.yml +220 -0
  33. package/.github/workflows/pr-title-check.yml +70 -0
  34. package/.github/workflows/publish.yml +39 -0
  35. package/.pipecraftrc.json +78 -0
  36. package/.release-it.cjs +71 -0
  37. package/PIPELINE_TESTING_PLAN.md +499 -0
  38. package/README.md +1101 -0
  39. package/TRUNK_FLOW_PLAN.md +401 -0
  40. package/assets/logo_banner.png +0 -0
  41. package/assets/logo_banner.webp +0 -0
  42. package/dist/cli/index.d.ts +3 -0
  43. package/dist/cli/index.d.ts.map +1 -0
  44. package/dist/cli/index.js +364 -0
  45. package/dist/cli/index.js.map +1 -0
  46. package/dist/generators/init.tpl.d.ts +3 -0
  47. package/dist/generators/init.tpl.d.ts.map +1 -0
  48. package/dist/generators/init.tpl.js +117 -0
  49. package/dist/generators/init.tpl.js.map +1 -0
  50. package/dist/generators/workflows.tpl.d.ts +7 -0
  51. package/dist/generators/workflows.tpl.d.ts.map +1 -0
  52. package/dist/generators/workflows.tpl.js +73 -0
  53. package/dist/generators/workflows.tpl.js.map +1 -0
  54. package/dist/templates/actions/calculate-version.yml.tpl.d.ts +3 -0
  55. package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -0
  56. package/dist/templates/actions/calculate-version.yml.tpl.js +122 -0
  57. package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -0
  58. package/dist/templates/actions/create-pr.yml.tpl.d.ts +3 -0
  59. package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -0
  60. package/dist/templates/actions/create-pr.yml.tpl.js +145 -0
  61. package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -0
  62. package/dist/templates/actions/create-tag.yml.tpl.d.ts +3 -0
  63. package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -0
  64. package/dist/templates/actions/create-tag.yml.tpl.js +111 -0
  65. package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -0
  66. package/dist/templates/actions/detect-changes.yml.tpl.d.ts +3 -0
  67. package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -0
  68. package/dist/templates/actions/detect-changes.yml.tpl.js +79 -0
  69. package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -0
  70. package/dist/templates/actions/manage-branch.yml.tpl.d.ts +3 -0
  71. package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -0
  72. package/dist/templates/actions/manage-branch.yml.tpl.js +130 -0
  73. package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -0
  74. package/dist/templates/actions/promote-branch.yml.tpl.d.ts +3 -0
  75. package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -0
  76. package/dist/templates/actions/promote-branch.yml.tpl.js +362 -0
  77. package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -0
  78. package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts +16 -0
  79. package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts.map +1 -0
  80. package/dist/templates/workflows/pipeline-path-based.yml.tpl.js +652 -0
  81. package/dist/templates/workflows/pipeline-path-based.yml.tpl.js.map +1 -0
  82. package/dist/types/index.d.ts +63 -0
  83. package/dist/types/index.d.ts.map +1 -0
  84. package/dist/types/index.js +2 -0
  85. package/dist/types/index.js.map +1 -0
  86. package/dist/utils/ast-path-operations.d.ts +287 -0
  87. package/dist/utils/ast-path-operations.d.ts.map +1 -0
  88. package/dist/utils/ast-path-operations.js +419 -0
  89. package/dist/utils/ast-path-operations.js.map +1 -0
  90. package/dist/utils/config.d.ts +3 -0
  91. package/dist/utils/config.d.ts.map +1 -0
  92. package/dist/utils/config.js +49 -0
  93. package/dist/utils/config.js.map +1 -0
  94. package/dist/utils/github-setup.d.ts +74 -0
  95. package/dist/utils/github-setup.d.ts.map +1 -0
  96. package/dist/utils/github-setup.js +418 -0
  97. package/dist/utils/github-setup.js.map +1 -0
  98. package/dist/utils/idempotency.d.ts +47 -0
  99. package/dist/utils/idempotency.d.ts.map +1 -0
  100. package/dist/utils/idempotency.js +176 -0
  101. package/dist/utils/idempotency.js.map +1 -0
  102. package/dist/utils/preflight.d.ts +55 -0
  103. package/dist/utils/preflight.d.ts.map +1 -0
  104. package/dist/utils/preflight.js +261 -0
  105. package/dist/utils/preflight.js.map +1 -0
  106. package/dist/utils/versioning.d.ts +41 -0
  107. package/dist/utils/versioning.d.ts.map +1 -0
  108. package/dist/utils/versioning.js +219 -0
  109. package/dist/utils/versioning.js.map +1 -0
  110. package/docs/USER_JOURNEY_ERRORS.md +352 -0
  111. package/eslint.config.js +77 -0
  112. package/examples/basic-config.json +41 -0
  113. package/examples/monorepo-config.json +49 -0
  114. package/examples/usage.md +289 -0
  115. package/package.json +58 -0
  116. package/scripts/debug-workflows.sh +339 -0
  117. package/scripts/parse-pipeline.js +29 -0
  118. package/scripts/test-job-order.cjs +140 -0
  119. package/scripts/validate-pipeline.cjs +379 -0
  120. package/scripts/verify-job-order.sh +30 -0
  121. package/src/cli/index.ts +414 -0
  122. package/src/generators/init.tpl.ts +126 -0
  123. package/src/generators/workflows.tpl.ts +80 -0
  124. package/src/templates/actions/calculate-version.yml.tpl.ts +124 -0
  125. package/src/templates/actions/create-pr.yml.tpl.ts +147 -0
  126. package/src/templates/actions/create-tag.yml.tpl.ts +112 -0
  127. package/src/templates/actions/detect-changes.yml.tpl.ts +87 -0
  128. package/src/templates/actions/manage-branch.yml.tpl.ts +132 -0
  129. package/src/templates/actions/promote-branch.yml.tpl.ts +364 -0
  130. package/src/templates/workflows/pipeline-path-based.yml.tpl.ts +706 -0
  131. package/src/types/index.ts +64 -0
  132. package/src/utils/README-ast-path-operations.md +390 -0
  133. package/src/utils/ast-path-operations.ts +581 -0
  134. package/src/utils/config.ts +64 -0
  135. package/src/utils/github-setup.ts +558 -0
  136. package/src/utils/idempotency.ts +215 -0
  137. package/src/utils/preflight.ts +306 -0
  138. package/src/utils/versioning.ts +244 -0
  139. package/tests/README.md +229 -0
  140. package/tests/TEST_STRUCTURE.md +256 -0
  141. package/tests/act/run-act-tests.sh +345 -0
  142. package/tests/debugging/debug-utils.ts +538 -0
  143. package/tests/debugging/debug-workflow.test.ts +339 -0
  144. package/tests/debugging/debug-workflows.sh +339 -0
  145. package/tests/debugging/iterative-debug.ts +652 -0
  146. package/tests/debugging/run-debug-tests.sh +431 -0
  147. package/tests/fixtures/basic-config.json +51 -0
  148. package/tests/fixtures/invalid-config.json +9 -0
  149. package/tests/fixtures/pipeline-generated.yml +235 -0
  150. package/tests/fixtures/pipeline-preserve-comments.yml +245 -0
  151. package/tests/fixtures/pipeline-user-modified.yml +245 -0
  152. package/tests/fixtures/test-config.json +58 -0
  153. package/tests/github-live/README.md +250 -0
  154. package/tests/github-local/JOB_WORKFLOW_TESTS.md +296 -0
  155. package/tests/github-local/README.md +240 -0
  156. package/tests/github-local/run-all-tests.sh +422 -0
  157. package/tests/github-local/test-job-workflows.sh +631 -0
  158. package/tests/github-local/test-pipeline-workflow.sh +440 -0
  159. package/tests/integration/generators.test.ts +578 -0
  160. package/tests/integration/path-based-template.test.ts +510 -0
  161. package/tests/integration/simple-path-based.test.ts +415 -0
  162. package/tests/setup.ts +56 -0
  163. package/tests/unit/ast-path-operations-extended.test.ts +302 -0
  164. package/tests/unit/cli.test.ts +541 -0
  165. package/tests/unit/config-extended.test.ts +412 -0
  166. package/tests/unit/config.test.ts +152 -0
  167. package/tests/unit/github-setup.test.ts +189 -0
  168. package/tests/unit/idempotency-isolated.test.ts +297 -0
  169. package/tests/unit/job-order.test.ts +157 -0
  170. package/tests/unit/pipeline-path-based.test.ts +511 -0
  171. package/tests/unit/validate-pipeline.test.ts +384 -0
  172. package/tests/unit/versioning-extended.test.ts +279 -0
  173. package/tests/unit/versioning.test.ts +241 -0
  174. package/tsconfig.debug.json +17 -0
  175. package/tsconfig.json +28 -0
  176. package/vitest.config.ts +51 -0
@@ -0,0 +1,362 @@
1
+ import { toFile, renderTemplate } from '@featherscloud/pinion';
2
+ import fs from 'fs';
3
+ import dedent from 'dedent';
4
+ // Template for the Promote Branch GitHub Action
5
+ // This action handles branch promotions via temporary branches + PRs
6
+ const promoteBranchActionTemplate = (ctx) => {
7
+ return dedent `name: 'Promote Branch'
8
+ description: 'Promote code from source to target branch via temporary branch + PR'
9
+ author: 'PipeCraft'
10
+
11
+ inputs:
12
+ sourceBranch:
13
+ description: 'Source branch to promote from (defaults to github.ref_name)'
14
+ required: false
15
+ default: \${{ github.ref_name }}
16
+ version:
17
+ description: 'Version being promoted (e.g., v1.2.3, auto-detected from git tags if not provided)'
18
+ required: false
19
+ default: ''
20
+ configPath:
21
+ description: 'Path to .pipecraftrc.json config file'
22
+ required: false
23
+ default: '.pipecraftrc.json'
24
+ tempBranchPattern:
25
+ description: 'Pattern for temp branch name'
26
+ required: false
27
+ default: 'release/{source}-to-{target}-{version}'
28
+ token:
29
+ description: 'GitHub token for authentication'
30
+ required: false
31
+ default: \${{ github.token }}
32
+
33
+ outputs:
34
+ prNumber:
35
+ description: 'The created PR number'
36
+ value: \${{ steps.create-pr.outputs.prNumber }}
37
+ prUrl:
38
+ description: 'The created PR URL'
39
+ value: \${{ steps.create-pr.outputs.prUrl }}
40
+ tempBranch:
41
+ description: 'The temporary branch name'
42
+ value: \${{ steps.create-temp.outputs.tempBranch }}
43
+ targetBranch:
44
+ description: 'The target branch determined from config'
45
+ value: \${{ steps.read-config.outputs.targetBranch }}
46
+ autoMerge:
47
+ description: 'The autoMerge setting for the target branch'
48
+ value: \${{ steps.read-config.outputs.autoMerge }}
49
+
50
+ runs:
51
+ using: 'composite'
52
+ steps:
53
+ - name: Checkout Code
54
+ uses: actions/checkout@v4
55
+ with:
56
+ fetch-depth: 0
57
+ token: \${{ inputs.token }}
58
+
59
+ - name: Read Config and Determine Target Branch
60
+ id: read-config
61
+ shell: bash
62
+ run: |
63
+ SOURCE="\${{ inputs.sourceBranch }}"
64
+ CONFIG_PATH="\${{ inputs.configPath }}"
65
+
66
+ echo "๐Ÿ“– Reading config from \$CONFIG_PATH"
67
+
68
+ # Check if config file exists
69
+ if [ ! -f "\$CONFIG_PATH" ]; then
70
+ echo "โŒ Config file not found: \$CONFIG_PATH"
71
+ exit 1
72
+ fi
73
+
74
+ # Read branchFlow array from config
75
+ BRANCH_FLOW=\$(cat "\$CONFIG_PATH" | jq -r '.branchFlow | join(" ")')
76
+ echo "๐Ÿ” Branch flow: \$BRANCH_FLOW"
77
+
78
+ # Convert to array
79
+ IFS=' ' read -ra BRANCHES <<< "\$BRANCH_FLOW"
80
+
81
+ # Find current branch index and determine target
82
+ TARGET=""
83
+ for i in "\${!BRANCHES[@]}"; do
84
+ if [ "\${BRANCHES[\$i]}" == "\$SOURCE" ]; then
85
+ # Get next branch in flow
86
+ NEXT_INDEX=\$((i + 1))
87
+ if [ \$NEXT_INDEX -lt \${#BRANCHES[@]} ]; then
88
+ TARGET="\${BRANCHES[\$NEXT_INDEX]}"
89
+ fi
90
+ break
91
+ fi
92
+ done
93
+
94
+ if [ -z "\$TARGET" ]; then
95
+ echo "โŒ Could not determine target branch for source: \$SOURCE"
96
+ echo " Branch flow: \$BRANCH_FLOW"
97
+ exit 1
98
+ fi
99
+
100
+ echo "โœ… Target branch: \$TARGET"
101
+ echo "targetBranch=\$TARGET" >> \$GITHUB_OUTPUT
102
+
103
+ # Determine autoMerge setting for target branch
104
+ AUTO_MERGE=\$(cat "\$CONFIG_PATH" | jq -r ".autoMerge.\"\$TARGET\" // false")
105
+ echo "๐Ÿ” Auto-merge for \$TARGET: \$AUTO_MERGE"
106
+ echo "autoMerge=\$AUTO_MERGE" >> \$GITHUB_OUTPUT
107
+
108
+ - name: Get Version
109
+ id: get-version
110
+ shell: bash
111
+ run: |
112
+ VERSION_INPUT="\${{ inputs.version }}"
113
+
114
+ if [ -n "\$VERSION_INPUT" ]; then
115
+ VERSION="\$VERSION_INPUT"
116
+ echo "๐Ÿ“Œ Using provided version: \$VERSION"
117
+ else
118
+ # Auto-detect from git tags
119
+ VERSION=\$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0")
120
+ echo "๐Ÿท๏ธ Auto-detected version from tags: \$VERSION"
121
+ fi
122
+
123
+ echo "version=\$VERSION" >> \$GITHUB_OUTPUT
124
+
125
+ - name: Create Temporary Branch
126
+ id: create-temp
127
+ shell: bash
128
+ run: |
129
+ SOURCE="\${{ inputs.sourceBranch }}"
130
+ TARGET="\${{ steps.read-config.outputs.targetBranch }}"
131
+ VERSION="\${{ steps.get-version.outputs.version }}"
132
+ PATTERN="\${{ inputs.tempBranchPattern }}"
133
+
134
+ # Remove 'v' prefix from version for branch name
135
+ VERSION_CLEAN="\${VERSION#v}"
136
+
137
+ # Replace placeholders in pattern
138
+ TEMP_BRANCH="\$PATTERN"
139
+ TEMP_BRANCH="\${TEMP_BRANCH//\{source\}/\$SOURCE}"
140
+ TEMP_BRANCH="\${TEMP_BRANCH//\{target\}/\$TARGET}"
141
+ TEMP_BRANCH="\${TEMP_BRANCH//\{version\}/\$VERSION_CLEAN}"
142
+
143
+ echo "๐ŸŒฟ Preparing temporary branch: \$TEMP_BRANCH"
144
+ echo " From: \$SOURCE"
145
+ echo " To: \$TARGET"
146
+ echo " Version: \$VERSION"
147
+
148
+ # Ensure we're on the source branch
149
+ git checkout "\$SOURCE"
150
+
151
+ # Check if temp branch already exists locally or remotely
152
+ if git show-ref --verify --quiet refs/heads/"\$TEMP_BRANCH" || git ls-remote --heads origin "\$TEMP_BRANCH" | grep -q "\$TEMP_BRANCH"; then
153
+ echo "โš ๏ธ Temp branch \$TEMP_BRANCH already exists, using existing branch"
154
+ # Fetch and checkout existing branch
155
+ git fetch origin "\$TEMP_BRANCH" 2>/dev/null || true
156
+ git checkout "\$TEMP_BRANCH" 2>/dev/null || git checkout -b "\$TEMP_BRANCH" origin/"\$TEMP_BRANCH"
157
+ else
158
+ echo "๐Ÿ“ Creating new temp branch \$TEMP_BRANCH"
159
+ # Create temp branch from current commit
160
+ git checkout -b "\$TEMP_BRANCH"
161
+ # Push temp branch to remote
162
+ git push origin "\$TEMP_BRANCH"
163
+ fi
164
+
165
+ echo "tempBranch=\$TEMP_BRANCH" >> \$GITHUB_OUTPUT
166
+ echo "โœ… Temporary branch ready"
167
+
168
+ - name: Check for Existing PR
169
+ id: check-pr
170
+ shell: bash
171
+ env:
172
+ GH_TOKEN: \${{ inputs.token }}
173
+ run: |
174
+ TEMP_BRANCH="\${{ steps.create-temp.outputs.tempBranch }}"
175
+ TARGET="\${{ steps.read-config.outputs.targetBranch }}"
176
+
177
+ # Check if PR already exists from temp branch to target
178
+ EXISTING_PR=\$(gh pr list --head "\$TEMP_BRANCH" --base "\$TARGET" --json number --jq '.[0].number' 2>/dev/null || echo "")
179
+
180
+ if [ -n "\$EXISTING_PR" ]; then
181
+ echo "exists=true" >> \$GITHUB_OUTPUT
182
+ echo "prNumber=\$EXISTING_PR" >> \$GITHUB_OUTPUT
183
+ echo "โš ๏ธ PR already exists: #\$EXISTING_PR"
184
+
185
+ # Get PR URL
186
+ PR_URL=\$(gh pr view "\$EXISTING_PR" --json url --jq '.url')
187
+ echo "prUrl=\$PR_URL" >> \$GITHUB_OUTPUT
188
+ else
189
+ echo "exists=false" >> \$GITHUB_OUTPUT
190
+ echo "โœ… No existing PR found"
191
+ fi
192
+
193
+ - name: Create Pull Request
194
+ id: create-pr
195
+ if: steps.check-pr.outputs.exists == 'false'
196
+ shell: bash
197
+ env:
198
+ GH_TOKEN: \${{ inputs.token }}
199
+ run: |
200
+ TEMP_BRANCH="\${{ steps.create-temp.outputs.tempBranch }}"
201
+ TARGET="\${{ steps.read-config.outputs.targetBranch }}"
202
+ SOURCE="\${{ inputs.sourceBranch }}"
203
+ VERSION="\${{ steps.get-version.outputs.version }}"
204
+ AUTO_MERGE="\${{ steps.read-config.outputs.autoMerge }}"
205
+
206
+ TITLE="๐Ÿš€ Release \$VERSION to \$TARGET"
207
+
208
+ # Determine merge behavior text
209
+ if [ "\$AUTO_MERGE" == "true" ]; then
210
+ MERGE_TEXT="merge automatically"
211
+ else
212
+ MERGE_TEXT="require manual approval"
213
+ fi
214
+
215
+ # Disable error exit to capture gh pr create output even on failure
216
+ set +e
217
+
218
+ # Create the PR - gh pr create returns the PR URL on success
219
+ PR_URL=\$(gh pr create \\
220
+ --title "\$TITLE" \\
221
+ --body "Release \$VERSION from \$SOURCE to \$TARGET" \\
222
+ --head "\$TEMP_BRANCH" \\
223
+ --base "\$TARGET" 2>&1)
224
+ PR_EXIT_CODE=\$?
225
+
226
+ # Re-enable error exit
227
+ set -e
228
+
229
+ if [ \$PR_EXIT_CODE -eq 0 ] && [[ "\$PR_URL" =~ ^https://github.com/.*/pull/[0-9]+$ ]]; then
230
+ # Extract PR number from URL (e.g., https://github.com/owner/repo/pull/123)
231
+ PR_NUMBER=\$(echo "\$PR_URL" | grep -oE '[0-9]+$')
232
+ echo "prNumber=\$PR_NUMBER" >> \$GITHUB_OUTPUT
233
+ echo "prUrl=\$PR_URL" >> \$GITHUB_OUTPUT
234
+ echo "โœ… Created PR #\$PR_NUMBER"
235
+ echo "๐Ÿ”— URL: \$PR_URL"
236
+ else
237
+ echo "โŒ Failed to create PR"
238
+ echo "Error output:"
239
+ echo "\$PR_URL"
240
+ exit 1
241
+ fi
242
+
243
+ - name: Enable PR Auto-Merge with Rebase (Manual Approval Required)
244
+ if: steps.read-config.outputs.autoMerge == 'false'
245
+ shell: bash
246
+ env:
247
+ GH_TOKEN: \${{ inputs.token }}
248
+ run: |
249
+ PR_NUMBER="\${{ steps.check-pr.outputs.prNumber || steps.create-pr.outputs.prNumber }}"
250
+ TARGET="\${{ steps.read-config.outputs.targetBranch }}"
251
+
252
+ echo "๐Ÿ” Enabling auto-merge with rebase for PR #\$PR_NUMBER (requires approval)"
253
+ echo " This will fast-forward \$TARGET when approved, maintaining linear history"
254
+
255
+ # Enable auto-merge with rebase method (fast-forward, no merge commit)
256
+ gh pr merge "\$PR_NUMBER" --auto --rebase
257
+
258
+ echo "โœ… Auto-merge enabled - PR will fast-forward merge when approved"
259
+ echo "โš ๏ธ Manual approval required before merge completes"
260
+
261
+ - name: Fast-Forward Merge (Immediate Auto-Merge)
262
+ if: steps.read-config.outputs.autoMerge == 'true'
263
+ shell: bash
264
+ run: |
265
+ SOURCE="\${{ inputs.sourceBranch }}"
266
+ TARGET="\${{ steps.read-config.outputs.targetBranch }}"
267
+ VERSION="\${{ steps.get-version.outputs.version }}"
268
+
269
+ echo "๐Ÿš€ Fast-forwarding \$TARGET to \$SOURCE (maintaining linear history)"
270
+
271
+ # Get the commit SHA from source branch
272
+ COMMIT_SHA=\$(git rev-parse \$SOURCE)
273
+ echo "Source commit: \$COMMIT_SHA"
274
+
275
+ # Fetch target branch
276
+ git fetch origin \$TARGET:\$TARGET 2>/dev/null || true
277
+
278
+ # Checkout target branch
279
+ git checkout \$TARGET
280
+
281
+ # Verify we can fast-forward (no divergent commits)
282
+ if git merge-base --is-ancestor \$TARGET \$SOURCE; then
283
+ echo "โœ… Fast-forward is possible (linear history maintained)"
284
+ else
285
+ echo "โŒ Cannot fast-forward - branches have diverged"
286
+ echo "Target branch has commits not in source branch"
287
+ exit 1
288
+ fi
289
+
290
+ # Fast-forward merge (no merge commit)
291
+ git merge --ff-only \$SOURCE
292
+
293
+ # Push to remote
294
+ git push origin \$TARGET
295
+
296
+ echo "โœ… Fast-forwarded \$TARGET to \$COMMIT_SHA"
297
+ echo "๐Ÿ“ PR will be closed automatically for audit trail"
298
+
299
+ - name: Trigger Pipeline Workflow on Target Branch
300
+ if: steps.read-config.outputs.autoMerge == 'true'
301
+ shell: bash
302
+ env:
303
+ GH_TOKEN: \${{ inputs.token }}
304
+ run: |
305
+ TARGET="\${{ steps.read-config.outputs.targetBranch }}"
306
+ VERSION="\${{ steps.get-version.outputs.version }}"
307
+
308
+ echo "๐Ÿ”„ Triggering pipeline workflow on \$TARGET branch with version \$VERSION"
309
+
310
+ # Trigger the pipeline workflow on the target branch
311
+ # This is necessary because GITHUB_TOKEN pushes don't trigger workflows by default
312
+ # Pass the version so the run name is descriptive
313
+ gh workflow run pipeline.yml --ref "\$TARGET" --field version="\$VERSION"
314
+
315
+ echo "โœ… Pipeline workflow triggered on \$TARGET with version \$VERSION"
316
+
317
+ - name: Close PR and Delete Branch
318
+ if: steps.read-config.outputs.autoMerge == 'true'
319
+ shell: bash
320
+ env:
321
+ GH_TOKEN: \${{ inputs.token }}
322
+ run: |
323
+ TEMP_BRANCH="\${{ steps.create-temp.outputs.tempBranch }}"
324
+ PR_NUMBER="\${{ steps.check-pr.outputs.prNumber || steps.create-pr.outputs.prNumber }}"
325
+
326
+ echo "๐Ÿงน Cleaning up temporary branch: \$TEMP_BRANCH"
327
+
328
+ # Close the PR (it's already been fast-forward merged)
329
+ if [ -n "\$PR_NUMBER" ]; then
330
+ gh pr close "\$PR_NUMBER" --comment "Automatically merged via fast-forward. Closing PR and cleaning up release branch." || true
331
+ echo "โœ… Closed PR #\$PR_NUMBER"
332
+ fi
333
+
334
+ # Delete the temporary branch from remote
335
+ git push origin --delete "\$TEMP_BRANCH" || echo "โš ๏ธ Branch may already be deleted"
336
+
337
+ echo "โœ… Deleted temporary branch \$TEMP_BRANCH"
338
+
339
+ - name: Use Existing PR
340
+ if: steps.check-pr.outputs.exists == 'true'
341
+ shell: bash
342
+ run: |
343
+ PR_NUMBER="\${{ steps.check-pr.outputs.prNumber }}"
344
+ PR_URL="\${{ steps.check-pr.outputs.prUrl }}"
345
+
346
+ echo "โ„น๏ธ Using existing PR #\$PR_NUMBER"
347
+ echo "๐Ÿ”— URL: \$PR_URL"
348
+
349
+ # Note: Fast-forward merge happens in separate step if autoMerge is enabled
350
+ `;
351
+ };
352
+ export const generate = (ctx) => Promise.resolve(ctx)
353
+ .then((ctx) => {
354
+ // Check if file exists to determine merge status
355
+ const filePath = '.github/actions/promote-branch/action.yml';
356
+ const exists = fs.existsSync(filePath);
357
+ const status = exists ? '๐Ÿ”„ Merged with existing' : '๐Ÿ“ Created new';
358
+ console.log(`${status} ${filePath}`);
359
+ return ctx;
360
+ })
361
+ .then(renderTemplate(promoteBranchActionTemplate, toFile('.github/actions/promote-branch/action.yml')));
362
+ //# sourceMappingURL=promote-branch.yml.tpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promote-branch.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/promote-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,gDAAgD;AAChD,qEAAqE;AACrE,MAAM,2BAA2B,GAAG,CAAC,GAAQ,EAAE,EAAE;IAC/C,OAAO,MAAM,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuVZ,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAkB,EAAE,EAAE,CAC7C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;KACjB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;IACZ,iDAAiD;IACjD,MAAM,QAAQ,GAAG,2CAA2C,CAAA;IAC5D,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,gBAAgB,CAAA;IACpE,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAA;IACpC,OAAO,GAAG,CAAA;AACZ,CAAC,CAAC;KACD,IAAI,CAAC,cAAc,CAAC,2BAA2B,EAAE,MAAM,CAAC,2CAA2C,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { PinionContext } from '@featherscloud/pinion';
2
+ /**
3
+ * Create path-based pipeline content
4
+ */
5
+ export declare const createPathBasedPipeline: (ctx: any) => {
6
+ yamlContent: string;
7
+ mergeStatus: string;
8
+ };
9
+ /**
10
+ * Main export - path-based pipeline generator
11
+ */
12
+ export declare const generate: (ctx: PinionContext & {
13
+ existingPipeline?: any;
14
+ outputPipelinePath?: string;
15
+ }) => Promise<any>;
16
+ //# sourceMappingURL=pipeline-path-based.yml.tpl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline-path-based.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/workflows/pipeline-path-based.yml.tpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AA8D7E;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,KAAK,GAAG;;;CA2lB/C,CAAA;AAcD;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,GAAG;IAAE,gBAAgB,CAAC,EAAE,GAAG,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAE,iBAoB/F,CAAA"}