-
Notifications
You must be signed in to change notification settings - Fork 3
169 lines (159 loc) Β· 7.31 KB
/
test-on-push.yml
File metadata and controls
169 lines (159 loc) Β· 7.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: "TEST: On Push to Test Branch"
# ============================================================================
# SANDBOX TEST WORKFLOW - Phase 8A
# Mirrors on-push-master.yml but tracks test-auto-generate branch and test
# directories. Publish/release jobs echo success instead of real actions.
# Incorporates fix for Issue 6 (env block for commit message).
# DELETE THIS FILE after Phase 8A testing is complete.
# ============================================================================
on:
push:
branches: [test-auto-generate]
paths:
- 'test-v20111101/**'
- 'test-v20250224/**'
repository_dispatch:
types: [test_push_to_branch]
jobs:
# Check for skip-publish flag in commit message
# *** ISSUE 6 FIX: Uses env block instead of inline interpolation ***
check-skip-publish:
runs-on: ubuntu-latest
outputs:
skip_publish: ${{ steps.check.outputs.skip_publish }}
steps:
- name: Check for [skip-publish] flag in commit message
id: check
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
run: |
echo "π Commit message: $COMMIT_MSG"
if [[ "$COMMIT_MSG" == *"[skip-publish]"* ]]; then
echo "skip_publish=true" >> $GITHUB_OUTPUT
echo "π« [skip-publish] flag detected - skipping all publish/release jobs"
else
echo "skip_publish=false" >> $GITHUB_OUTPUT
echo "β
No skip flag - proceeding with publish/release"
fi
# Detect which test API versions were modified
# On repository_dispatch: versions come from client payload (paths-filter can't
# detect changes correctly because dispatch runs on master, not test-auto-generate)
# On push: use paths-filter as normal (push events have correct git context)
# NOTE: This is a SANDBOX-ONLY workaround. Production on-push-master.yml does NOT
# need this because both push and dispatch target master (same branch = correct context).
detect-changes:
runs-on: ubuntu-latest
outputs:
test_v20111101: ${{ steps.result.outputs.test_v20111101 }}
test_v20250224: ${{ steps.result.outputs.test_v20250224 }}
steps:
- uses: actions/checkout@v3
- name: Detect from dispatch payload
id: dispatch
if: github.event_name == 'repository_dispatch'
run: |
VERSIONS="${{ github.event.client_payload.versions }}"
echo "π Dispatch payload versions: $VERSIONS"
[[ "$VERSIONS" == *"v20111101"* ]] && echo "test_v20111101=true" >> $GITHUB_OUTPUT || echo "test_v20111101=false" >> $GITHUB_OUTPUT
[[ "$VERSIONS" == *"v20250224"* ]] && echo "test_v20250224=true" >> $GITHUB_OUTPUT || echo "test_v20250224=false" >> $GITHUB_OUTPUT
- name: Detect from push paths
id: filter
if: github.event_name == 'push'
uses: dorny/paths-filter@v2
with:
filters: |
test_v20111101:
- 'test-v20111101/**'
test_v20250224:
- 'test-v20250224/**'
- name: Set outputs
id: result
run: |
if [ "${{ github.event_name }}" = "repository_dispatch" ]; then
echo "test_v20111101=${{ steps.dispatch.outputs.test_v20111101 }}" >> $GITHUB_OUTPUT
echo "test_v20250224=${{ steps.dispatch.outputs.test_v20250224 }}" >> $GITHUB_OUTPUT
echo "π Using dispatch-based detection"
else
echo "test_v20111101=${{ steps.filter.outputs.test_v20111101 }}" >> $GITHUB_OUTPUT
echo "test_v20250224=${{ steps.filter.outputs.test_v20250224 }}" >> $GITHUB_OUTPUT
echo "π Using paths-filter-based detection"
fi
echo "π test_v20111101=${{ steps.dispatch.outputs.test_v20111101 || steps.filter.outputs.test_v20111101 }}"
echo "π test_v20250224=${{ steps.dispatch.outputs.test_v20250224 || steps.filter.outputs.test_v20250224 }}"
# Simulated publish and release for each version conditionally
# Same conditional structure as production but echoes success instead of real npm publish/GitHub release
publish-test-v20111101:
needs: [check-skip-publish, detect-changes]
if: needs.check-skip-publish.outputs.skip_publish == 'false' && needs.detect-changes.outputs.test_v20111101 == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: test-auto-generate
- name: Simulate publish
run: |
VERSION=$(jq -r '.version' ./test-v20111101/package.json)
echo "============================================"
echo "β
PUBLISH SUCCESS (simulated)"
echo " Package: mx-platform-node@$VERSION"
echo " Directory: test-v20111101/"
echo " Would run: npm publish from test-v20111101/"
echo "============================================"
release-test-v20111101:
needs: [check-skip-publish, detect-changes, publish-test-v20111101]
if: needs.check-skip-publish.outputs.skip_publish == 'false' && needs.detect-changes.outputs.test_v20111101 == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: test-auto-generate
- name: Simulate release
run: |
VERSION=$(jq -r '.version' ./test-v20111101/package.json)
echo "============================================"
echo "β
RELEASE SUCCESS (simulated)"
echo " Tag: v$VERSION"
echo " Directory: test-v20111101/"
echo " Would create: GitHub release for v$VERSION"
echo "============================================"
delay-for-test-v20250224:
runs-on: ubuntu-latest
needs: [check-skip-publish, detect-changes]
if: needs.check-skip-publish.outputs.skip_publish == 'false'
steps:
- name: Brief delay to stagger v20250224 publish
run: sleep 2
publish-test-v20250224:
needs: [check-skip-publish, detect-changes, delay-for-test-v20250224]
if: needs.check-skip-publish.outputs.skip_publish == 'false' && needs.detect-changes.outputs.test_v20250224 == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: test-auto-generate
- name: Simulate publish
run: |
VERSION=$(jq -r '.version' ./test-v20250224/package.json)
echo "============================================"
echo "β
PUBLISH SUCCESS (simulated)"
echo " Package: mx-platform-node@$VERSION"
echo " Directory: test-v20250224/"
echo " Would run: npm publish from test-v20250224/"
echo "============================================"
release-test-v20250224:
needs: [check-skip-publish, detect-changes, publish-test-v20250224]
if: needs.check-skip-publish.outputs.skip_publish == 'false' && needs.detect-changes.outputs.test_v20250224 == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: test-auto-generate
- name: Simulate release
run: |
VERSION=$(jq -r '.version' ./test-v20250224/package.json)
echo "============================================"
echo "β
RELEASE SUCCESS (simulated)"
echo " Tag: v$VERSION"
echo " Directory: test-v20250224/"
echo " Would create: GitHub release for v$VERSION"
echo "============================================"