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,38 @@
1
+ name: "Tag"
2
+
3
+ on:
4
+ workflow_call:
5
+ inputs:
6
+ version:
7
+ description: 'The version to deploy'
8
+ required: true
9
+ type: string
10
+ workflow_dispatch:
11
+
12
+ jobs:
13
+ tag:
14
+ if: github.ref_name == 'develop'
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+
18
+ - name: Checkout Code
19
+ uses: actions/checkout@v4
20
+ with:
21
+ fetch-depth: 0 # Ensures full history for rebase
22
+
23
+ - name: Create Tag
24
+ run: |
25
+ git config --global user.name "github-actions[bot]"
26
+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
27
+
28
+ NEWEST_VERSION=${{ inputs.version }}
29
+ LAST_TAG=$(git describe --tags --abbrev=0)
30
+
31
+ if [ "$LAST_TAG" != "$NEWEST_VERSION" ]; then
32
+ git tag $NEWEST_VERSION
33
+ git push origin $NEWEST_VERSION
34
+
35
+ echo "Creating new tag for version: ${LAST_TAG} -> ${NEWEST_VERSION}"
36
+ else
37
+ echo "Version already tagged. Skipping tag step."
38
+ fi
@@ -0,0 +1,99 @@
1
+ name: Versioning
2
+
3
+ on:
4
+ workflow_call:
5
+ outputs:
6
+ version:
7
+ description: "The determined version"
8
+ value: ${{ jobs.determine-version.outputs.version }}
9
+
10
+ jobs:
11
+
12
+ confirm-pass:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Confirm pass
16
+ run: exit 0
17
+
18
+
19
+ determine-version:
20
+ runs-on: ubuntu-latest
21
+ if: ${{ github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/test' || github.ref == 'refs/heads/main' }}
22
+ outputs:
23
+ version: ${{ steps.set_version.outputs.version }}
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ with:
27
+ fetch-depth: 0
28
+
29
+ - name: Install Node.js
30
+ uses: actions/setup-node@v4
31
+ with:
32
+ node-version: 22
33
+
34
+ - name: Configure Git
35
+ run: |
36
+ git config --global user.name "github-actions[bot]"
37
+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
38
+
39
+ - name: Get existing version tag
40
+ id: get_version_old
41
+ run: |
42
+ set -x # Enable debugging output
43
+ # Get the current commit hash
44
+ git rev-parse HEAD
45
+ COMMIT_HASH=$(git rev-parse HEAD)
46
+ echo "Current commit hash: $COMMIT_HASH"
47
+
48
+ # Check for tags on the current commit
49
+ TAG=$(git tag --points-at $COMMIT_HASH | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' || true)
50
+ echo "Tags found: $TAG"
51
+
52
+ if [ -z "$TAG" ]; then
53
+ echo "No existing tag found on the current commit"
54
+ else
55
+ echo "Found existing tag: $TAG"
56
+ echo "version=$TAG" >> $GITHUB_OUTPUT
57
+ fi
58
+
59
+ - name: Set up minimal package.json
60
+ run: |
61
+ echo '{
62
+ "name": "temporary-lib",
63
+ "version": "0.0.0-release-it"
64
+ }' > package.json
65
+
66
+ - name: Install dependencies
67
+ run: npm install @release-it/conventional-changelog conventional-changelog-angular
68
+
69
+ - name: Get version
70
+ if:
71
+ id: get_version_new
72
+ run: |
73
+ VERSION=$(npx release-it --ci --release-version 2>&1 || echo "")
74
+ if [[ "$VERSION" == *"No new version to release"* || -z "$VERSION" ]]; then
75
+ echo "No new version to release"
76
+ echo "VERSION=" >> $GITHUB_ENV
77
+ echo "version=" >> $GITHUB_OUTPUT
78
+ else
79
+ echo "New version to release: $VERSION"
80
+ echo "VERSION=v$VERSION" >> $GITHUB_ENV
81
+ echo "version=v$VERSION" >> $GITHUB_OUTPUT
82
+ fi
83
+
84
+ - name: Set version output
85
+ id: set_version
86
+ run: |
87
+ if [ -n "${{ steps.get_version_old.outputs.version }}" ]; then
88
+ echo "Using old version: ${{ steps.get_version_old.outputs.version }}"
89
+ echo "version=${{ steps.get_version_old.outputs.version }}" >> $GITHUB_OUTPUT
90
+ elif [ -n "${{ steps.get_version_new.outputs.version }}" ]; then
91
+ echo "Using new version: ${{ steps.get_version_new.outputs.version }}"
92
+ echo "version=${{ steps.get_version_new.outputs.version }}" >> $GITHUB_OUTPUT
93
+ else
94
+ echo "No version determined"
95
+ echo "version=" >> $GITHUB_OUTPUT
96
+ fi
97
+
98
+ - name: Output version
99
+ run: 'echo "Version determined: ${{ steps.set_version.outputs.version }}"'
@@ -0,0 +1,59 @@
1
+ name: "PLUGIN:Base"
2
+
3
+ on:
4
+ push:
5
+ paths:
6
+ - 'libs/plugins/base-class/**' # the plugin folder
7
+ - '.github/workflows/plugin.base**' # this file and any related workflows
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ build:
12
+ name: "PLUGIN:Base:Publish to NPM"
13
+ runs-on: ubuntu-latest
14
+ env:
15
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Setup pnpm
21
+ uses: pnpm/action-setup@v4
22
+ with:
23
+ version: 9
24
+
25
+ - name: Use Node.js
26
+ uses: actions/setup-node@v4
27
+ with:
28
+ node-version: '18'
29
+ registry-url: 'https://registry.npmjs.org'
30
+ cache: 'pnpm'
31
+
32
+ - name: Configure root NPM Authentication
33
+ run: |
34
+ echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
35
+
36
+ - name: Install root dependencies
37
+ run: |
38
+ ls -la;
39
+ pnpm install --frozen-lockfile
40
+
41
+ - name: Get root version
42
+ id: get_version
43
+ run: |
44
+ VERSION=$(npx release-it --ci --dry-run | grep "New version" | awk '{print $NF}')
45
+ echo "VERSION=$VERSION" >> $GITHUB_ENV
46
+
47
+ - name: Configure Plugin NPM Authentication
48
+ run: |
49
+ cd libs/plugins/base-class;
50
+ echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
51
+
52
+ - name: Install dependencies
53
+ run: |
54
+ pnpm install --frozen-lockfile -F madi-plg-base-class
55
+
56
+ - name: Release
57
+ run: |
58
+ cd libs/plugins/base-class;
59
+ npx release-it $VERSION --ci --dry-run;
@@ -0,0 +1,178 @@
1
+ name: Test and Deploy
2
+
3
+ on:
4
+ push:
5
+ branches-ignore:
6
+ - 'temp-*'
7
+ workflow_dispatch:
8
+ inputs:
9
+ migration_input:
10
+ description: 'Perform Migration'
11
+ default: false
12
+ required: true
13
+ type: boolean
14
+ seed_input:
15
+ description: 'Perform Seed'
16
+ default: false
17
+ required: true
18
+ type: boolean
19
+
20
+
21
+ # Custom event type
22
+ jobs:
23
+
24
+ env-check:
25
+ secrets: inherit
26
+ uses: ./.github/workflows/job.env-check.yml
27
+
28
+ debug-env:
29
+ needs: [env-check]
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - name: Debug Environment Variables
33
+ run: |
34
+ echo "project_id: ${{ needs.env-check.outputs.project_id }}"
35
+ echo "bucket: ${{ needs.env-check.outputs.bucket }}"
36
+
37
+ # LINTING
38
+ lint:
39
+ secrets: inherit
40
+ uses: ./.github/workflows/job.lint.yml
41
+
42
+ # CHANGE DETECTION
43
+ changes:
44
+ secrets: inherit
45
+ uses: ./.github/workflows/job.changes.yml
46
+
47
+ # # SECURITY
48
+ code-analyze:
49
+ needs: [changes]
50
+ secrets: inherit
51
+ uses: ./.github/workflows/job.analyze.code.yml
52
+
53
+ docker-analyze:
54
+ needs: [changes]
55
+ secrets: inherit
56
+ uses: ./.github/workflows/job.analyze.docker.yml
57
+
58
+ # TESTING
59
+ api-test:
60
+ needs: [changes, lint]
61
+ if: ${{ needs.changes.outputs.api == 'true' }}
62
+ secrets: inherit
63
+ uses: ./.github/workflows/job.app.api.test.yml
64
+
65
+ web-test:
66
+ needs: [changes, lint]
67
+ if: ${{ needs.changes.outputs.web == 'true' }}
68
+ secrets: inherit
69
+ uses: ./.github/workflows/job.app.web.test.yml
70
+
71
+ docs-test:
72
+ needs: [changes, lint]
73
+ # Needs to be run even when updates are only to the website
74
+ # Could be updated, using rsync to just target the docs directory in GCS
75
+ if: ${{ needs.changes.outputs.docs == 'true' || needs.changes.outputs.web == 'true' }}
76
+ secrets: inherit
77
+ uses: ./.github/workflows/job.app.docs.test.yml
78
+
79
+
80
+ # VERSIONING
81
+ versioning:
82
+ needs: [api-test, web-test, docs-test, docker-analyze, code-analyze, changes, lint]
83
+ # allows the versioning job to run even if api-test or web-test is skipped
84
+ if:
85
+ ${{
86
+ always() && (
87
+ (
88
+ needs.api-test.result == 'success' ||
89
+ needs.web-test.result == 'success' ||
90
+ needs.docs-test.result == 'success' ||
91
+ needs.changes.outputs.cicd == 'true'
92
+ ) && (
93
+ needs.api-test.result != 'failure' &&
94
+ needs.web-test.result != 'failure' &&
95
+ needs.docs-test.result != 'failure' &&
96
+ needs.lint.result != 'failure'
97
+ )
98
+ ) || (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/test' || github.ref == 'refs/heads/main') }}
99
+ secrets: inherit
100
+ uses: ./.github/workflows/job.version.yml
101
+
102
+
103
+
104
+ # DEPLOYMENTS
105
+ api-deploy:
106
+ needs: [versioning, changes, env-check]
107
+ if: ${{
108
+ always() &&
109
+ needs.changes.outputs.api == 'true' &&
110
+ needs.versioning.outputs.version != '' && (
111
+ github.ref == 'refs/heads/develop' ||
112
+ github.ref == 'refs/heads/test' ||
113
+ github.ref == 'refs/heads/main'
114
+ ) }}
115
+ secrets: inherit
116
+ uses: ./.github/workflows/job.app.api.deploy.yml
117
+ with:
118
+ version: ${{ needs.versioning.outputs.version }}
119
+ project_id: ${{ needs.env-check.outputs.project_id }}
120
+
121
+ docs-deploy:
122
+ needs: [versioning, changes]
123
+ # Disabled and rolled into web-deploy
124
+ if: ${{ !always() && (needs.changes.outputs.docs == 'true') && needs.versioning.outputs.version != '' && github.ref == 'refs/heads/main' }}
125
+ secrets: inherit
126
+ uses: ./.github/workflows/job.app.docs.deploy.yml
127
+ with:
128
+ version: ${{ needs.versioning.outputs.version }}
129
+
130
+ web-deploy:
131
+ needs: [versioning, changes, env-check]
132
+ if:
133
+ ${{
134
+ always() && (
135
+ needs.changes.outputs.web == 'true' ||
136
+ needs.changes.outputs.docs == 'true'
137
+ ) && needs.versioning.outputs.version != '' && (
138
+ github.ref == 'refs/heads/develop' ||
139
+ github.ref == 'refs/heads/test' ||
140
+ github.ref == 'refs/heads/main'
141
+ ) }}
142
+ secrets: inherit
143
+ uses: ./.github/workflows/job.app.web.deploy.yml
144
+ with:
145
+ project_id: ${{ needs.env-check.outputs.project_id }}
146
+ bucket: ${{ needs.env-check.outputs.bucket }}
147
+
148
+ create-pr:
149
+ needs: [api-deploy, web-deploy, docs-deploy, versioning]
150
+ # runs if any of the deployments are successful and non-failure
151
+ # and the version is not empty
152
+ # and the branch is develop or test
153
+ if:
154
+ ${{
155
+ always() && (
156
+ (
157
+ needs.api-deploy.result == 'success' ||
158
+ needs.web-deploy.result == 'success' ||
159
+ needs.docs-deploy.result == 'success' ||
160
+ needs.versioning.result == 'success'
161
+ ) && (
162
+ needs.api-deploy.result != 'failure' &&
163
+ needs.web-deploy.result != 'failure' &&
164
+ needs.docs-deploy.result != 'failure' &&
165
+ needs.versioning.result != 'failure'
166
+ ) && needs.versioning.outputs.version != ''
167
+ ) && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/test') }}
168
+ secrets: inherit
169
+ uses: ./.github/workflows/job.create-pr.yml
170
+ with:
171
+ version: ${{ needs.versioning.outputs.version }}
172
+
173
+ tag-version:
174
+ needs: [create-pr, versioning]
175
+ if: ${{ always() && needs.versioning.outputs.version != '' }}
176
+ uses: ./.github/workflows/job.tag.yml
177
+ with:
178
+ version: ${{ needs.versioning.outputs.version }}
@@ -0,0 +1,51 @@
1
+ #!/bin/bash
2
+
3
+ # Set environment variables for testing
4
+ PR_HEAD="temp-test-v0.1.1" # Example PR head branch
5
+ PR_BASE="temp-test-v0.1.0" # Example PR base branch
6
+
7
+ # Verify PR Source is a Fake Branch
8
+ if [[ ! "$PR_HEAD" =~ ^temp-(test|main)-v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
9
+ echo "Skipping: PR did not come from an auto-generated fake branch."
10
+ exit 1
11
+ fi
12
+
13
+ # Extract version and base branch from the PR branch name
14
+ BASE_BRANCH=$(echo "$PR_BASE" | cut -d'-' -f1)
15
+ OLD_VERSION=$(echo "$PR_BASE" | cut -d'-' -f2-)
16
+ NEXT_VERSION=$(echo "$PR_HEAD" | cut -d'-' -f2-)
17
+
18
+ echo "BASE_BRANCH=$BASE_BRANCH"
19
+ echo "OLD_VERSION=$OLD_VERSION"
20
+ echo "NEXT_VERSION=$NEXT_VERSION"
21
+
22
+ # Checkout Repository
23
+ git fetch origin $PR_HEAD:$PR_HEAD
24
+ git checkout $PR_HEAD
25
+
26
+ # # Set Up Git
27
+ # git config user.name "github-actions[bot]"
28
+ # git config user.email "github-actions[bot]@users.noreply.github.com"
29
+
30
+ git rev-parse $PR_HEAD
31
+
32
+ # Get Latest Commit from Head Branch
33
+ COMMIT_HASH=$(git rev-parse $PR_HEAD)
34
+
35
+ if [[ -z "$COMMIT_HASH" ]]; then
36
+ echo "Failed to find commit for branch $PR_HEAD"
37
+ exit 1
38
+ fi
39
+
40
+ # echo "Found commit: $COMMIT_HASH"
41
+
42
+ # # Fast Forward Target Branch
43
+ # git fetch origin
44
+ # git checkout $BASE_BRANCH
45
+ # git merge --ff-only $COMMIT_HASH
46
+ # git push origin $BASE_BRANCH
47
+
48
+ # # Delete Temporary Branches
49
+ # NEW_BRANCH="temp-${BASE_BRANCH}-${NEXT_VERSION}"
50
+ # git push origin --delete $NEW_BRANCH
51
+ # echo "Temporary branch $NEW_BRANCH deleted"
@@ -0,0 +1,70 @@
1
+ #!/bin/bash
2
+
3
+ # Set variables
4
+ GITHUB_TOKEN=$GITHUB_PERSONAL_ACCESS_TOKEN # Replace with your GitHub token
5
+ REPO_OWNER="nasa-madi" # Replace with the repository owner (your GitHub username or org)
6
+ REPO_NAME="madi" # Replace with the repository name
7
+ OLDER_THAN_DATE="2025-03-11" # Specify the date in YYYY-MM-DD format, older workflows will be deleted
8
+
9
+ DRY_RUN=false
10
+
11
+ # Convert the date into a timestamp
12
+ DATE_TIMESTAMP=$(date -j -f "%Y-%m-%d" "$OLDER_THAN_DATE" "+%s")
13
+ echo $DATE_TIMESTAMP
14
+
15
+ # Loop through pages of workflow runs
16
+ PAGE=1
17
+ WORKFLOW_RUN_IDS=""
18
+ while true; do
19
+ echo "Page: $PAGE"
20
+ # Get a page of workflow runs for the repository
21
+ WORKFLOW_RUNS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
22
+ "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs?per_page=100&page=$PAGE")
23
+
24
+ # Clean the JSON response by removing newlines and replacing unescaped \n with \\n
25
+ CLEANED_WORKFLOW_RUNS=$(echo "$WORKFLOW_RUNS" | tr '\n' ' ' | sed 's/\\n/\\\\n/g')
26
+
27
+ # Extract the workflow run IDs and their created dates
28
+ PAGE_RUN_IDS=$(echo "$CLEANED_WORKFLOW_RUNS" | jq -r ".workflow_runs[] | select((.created_at | fromdateiso8601) < $DATE_TIMESTAMP ) | .id")
29
+
30
+ # Break the loop if no more runs are found
31
+ if [ -z "$PAGE_RUN_IDS" ]; then
32
+ break
33
+ fi
34
+
35
+ # Append the current page's run IDs to the list
36
+ WORKFLOW_RUN_IDS="$WORKFLOW_RUN_IDS $PAGE_RUN_IDS"
37
+
38
+ # Increment the page number
39
+ PAGE=$((PAGE + 1))
40
+ done
41
+
42
+ # # Get all workflow runs for the repository
43
+ # WORKFLOW_RUNS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
44
+ # "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs?per_page=100&page=2")
45
+
46
+ # # Clean the JSON response by removing newlines and replacing unescaped \n with \\n
47
+ # CLEANED_WORKFLOW_RUNS=$(echo "$WORKFLOW_RUNS" | tr '\n' ' ' | sed 's/\\n/\\\\n/g')
48
+
49
+ # WORKFLOW_RUN_IDS=$(echo "$CLEANED_WORKFLOW_RUNS" | jq -r ".workflow_runs[] | select((.created_at | fromdateiso8601) < $DATE_TIMESTAMP ) | .id")
50
+
51
+
52
+ echo "$WORKFLOW_RUN_IDS"
53
+
54
+ # Loop through and handle the workflow runs that are older than the specified date
55
+ for RUN_ID in $WORKFLOW_RUN_IDS; do
56
+ if [ "$DRY_RUN" = "true" ]; then
57
+ echo "Dry run: Would delete workflow run ID: $RUN_ID"
58
+ else
59
+ echo "Deleting workflow run ID: $RUN_ID"
60
+ DELETE_RESPONSE=$(curl -s -X DELETE -H "Authorization: token $GITHUB_TOKEN" \
61
+ "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs/$RUN_ID")
62
+
63
+ # Check if the deletion was successful
64
+ if [[ $(echo "$DELETE_RESPONSE" | jq -r '.message') == "Not Found" ]]; then
65
+ echo "Error: Failed to delete workflow run ID: $RUN_ID"
66
+ else
67
+ echo "Successfully deleted workflow run ID: $RUN_ID"
68
+ fi
69
+ fi
70
+ done
@@ -0,0 +1,51 @@
1
+ #!/bin/bash
2
+
3
+ # Set environment variables for testing
4
+ PR_HEAD="temp-test-v0.1.1" # Example PR head branch
5
+ PR_BASE="temp-test-v0.1.0" # Example PR base branch
6
+
7
+ # Verify PR Source is a Fake Branch
8
+ if [[ ! "$PR_HEAD" =~ ^temp-(test|main)-v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
9
+ echo "Skipping: PR did not come from an auto-generated fake branch."
10
+ exit 1
11
+ fi
12
+
13
+ # Extract version and base branch from the PR branch name
14
+ BASE_BRANCH=$(echo "$PR_BASE" | cut -d'-' -f1)
15
+ OLD_VERSION=$(echo "$PR_BASE" | cut -d'-' -f2-)
16
+ NEXT_VERSION=$(echo "$PR_HEAD" | cut -d'-' -f2-)
17
+
18
+ echo "BASE_BRANCH=$BASE_BRANCH"
19
+ echo "OLD_VERSION=$OLD_VERSION"
20
+ echo "NEXT_VERSION=$NEXT_VERSION"
21
+
22
+ # Checkout Repository
23
+ git fetch origin $PR_HEAD:$PR_HEAD
24
+ git checkout $PR_HEAD
25
+
26
+ # # Set Up Git
27
+ # git config user.name "github-actions[bot]"
28
+ # git config user.email "github-actions[bot]@users.noreply.github.com"
29
+
30
+ git rev-parse $PR_HEAD
31
+
32
+ # Get Latest Commit from Head Branch
33
+ COMMIT_HASH=$(git rev-parse $PR_HEAD)
34
+
35
+ if [[ -z "$COMMIT_HASH" ]]; then
36
+ echo "Failed to find commit for branch $PR_HEAD"
37
+ exit 1
38
+ fi
39
+
40
+ # echo "Found commit: $COMMIT_HASH"
41
+
42
+ # # Fast Forward Target Branch
43
+ # git fetch origin
44
+ # git checkout $BASE_BRANCH
45
+ # git merge --ff-only $COMMIT_HASH
46
+ # git push origin $BASE_BRANCH
47
+
48
+ # # Delete Temporary Branches
49
+ # NEW_BRANCH="temp-${BASE_BRANCH}-${NEXT_VERSION}"
50
+ # git push origin --delete $NEW_BRANCH
51
+ # echo "Temporary branch $NEW_BRANCH deleted"
@@ -0,0 +1,70 @@
1
+ #!/bin/bash
2
+
3
+ # Set variables
4
+ GITHUB_TOKEN=$GITHUB_PERSONAL_ACCESS_TOKEN # Replace with your GitHub token
5
+ REPO_OWNER="nasa-madi" # Replace with the repository owner (your GitHub username or org)
6
+ REPO_NAME="madi" # Replace with the repository name
7
+ OLDER_THAN_DATE="2025-03-11" # Specify the date in YYYY-MM-DD format, older workflows will be deleted
8
+
9
+ DRY_RUN=false
10
+
11
+ # Convert the date into a timestamp
12
+ DATE_TIMESTAMP=$(date -j -f "%Y-%m-%d" "$OLDER_THAN_DATE" "+%s")
13
+ echo $DATE_TIMESTAMP
14
+
15
+ # Loop through pages of workflow runs
16
+ PAGE=1
17
+ WORKFLOW_RUN_IDS=""
18
+ while true; do
19
+ echo "Page: $PAGE"
20
+ # Get a page of workflow runs for the repository
21
+ WORKFLOW_RUNS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
22
+ "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs?per_page=100&page=$PAGE")
23
+
24
+ # Clean the JSON response by removing newlines and replacing unescaped \n with \\n
25
+ CLEANED_WORKFLOW_RUNS=$(echo "$WORKFLOW_RUNS" | tr '\n' ' ' | sed 's/\\n/\\\\n/g')
26
+
27
+ # Extract the workflow run IDs and their created dates
28
+ PAGE_RUN_IDS=$(echo "$CLEANED_WORKFLOW_RUNS" | jq -r ".workflow_runs[] | select((.created_at | fromdateiso8601) < $DATE_TIMESTAMP ) | .id")
29
+
30
+ # Break the loop if no more runs are found
31
+ if [ -z "$PAGE_RUN_IDS" ]; then
32
+ break
33
+ fi
34
+
35
+ # Append the current page's run IDs to the list
36
+ WORKFLOW_RUN_IDS="$WORKFLOW_RUN_IDS $PAGE_RUN_IDS"
37
+
38
+ # Increment the page number
39
+ PAGE=$((PAGE + 1))
40
+ done
41
+
42
+ # # Get all workflow runs for the repository
43
+ # WORKFLOW_RUNS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
44
+ # "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs?per_page=100&page=2")
45
+
46
+ # # Clean the JSON response by removing newlines and replacing unescaped \n with \\n
47
+ # CLEANED_WORKFLOW_RUNS=$(echo "$WORKFLOW_RUNS" | tr '\n' ' ' | sed 's/\\n/\\\\n/g')
48
+
49
+ # WORKFLOW_RUN_IDS=$(echo "$CLEANED_WORKFLOW_RUNS" | jq -r ".workflow_runs[] | select((.created_at | fromdateiso8601) < $DATE_TIMESTAMP ) | .id")
50
+
51
+
52
+ echo "$WORKFLOW_RUN_IDS"
53
+
54
+ # Loop through and handle the workflow runs that are older than the specified date
55
+ for RUN_ID in $WORKFLOW_RUN_IDS; do
56
+ if [ "$DRY_RUN" = "true" ]; then
57
+ echo "Dry run: Would delete workflow run ID: $RUN_ID"
58
+ else
59
+ echo "Deleting workflow run ID: $RUN_ID"
60
+ DELETE_RESPONSE=$(curl -s -X DELETE -H "Authorization: token $GITHUB_TOKEN" \
61
+ "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs/$RUN_ID")
62
+
63
+ # Check if the deletion was successful
64
+ if [[ $(echo "$DELETE_RESPONSE" | jq -r '.message') == "Not Found" ]]; then
65
+ echo "Error: Failed to delete workflow run ID: $RUN_ID"
66
+ else
67
+ echo "Successfully deleted workflow run ID: $RUN_ID"
68
+ fi
69
+ fi
70
+ done