55 branches : [ main ]
66 paths-ignore :
77 - " QPK_PIN"
8+ - " constraints.txt"
89 - " docs/**"
910 - " **.md"
1011
1112permissions :
1213 contents : write
14+ pull-requests : write
1315
1416jobs :
1517 update-pin :
@@ -19,26 +21,31 @@ jobs:
1921 steps :
2022 - uses : actions/checkout@v6
2123
22- - name : Update QPK_PIN
24+ - name : Update QPK_PIN and constraints
25+ id : update
2326 run : |
2427 SHA=$(git rev-parse HEAD)
2528 echo "$SHA" > QPK_PIN
26- # Update constraints.txt with latest QPK SHA
27- sed -i "s|quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@[a-f0-9]*|quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@$SHA|" constraints.txt
28- # Fetch latest SHAs from all strategy repos and update constraints
29- for repo in UsEquityStrategies HkEquityStrategies CnEquityStrategies CryptoStrategies QuantUsComboStrategies; do
30- REMOTE_SHA=$(git ls-remote "https://github.com/QuantStrategyLab/$repo.git" HEAD | cut -f1)
31- [ -n "$REMOTE_SHA" ] && sed -i "s|${repo,,} @ git+https://github.com/QuantStrategyLab/$repo.git@[a-f0-9]*|${repo,,} @ git+https://github.com/QuantStrategyLab/$repo.git@$REMOTE_SHA|" constraints.txt || true
29+
30+ # Update SHAs from remote repos
31+ for repo in UsEquityStrategies HkEquityStrategies CnEquityStrategies CryptoStrategies; do
32+ RSHA=$(git ls-remote "https://github.com/QuantStrategyLab/$repo.git" HEAD | cut -f1)
33+ [ -n "$RSHA" ] && sed -i "s|${repo,,} @ git+https://github.com/QuantStrategyLab/$repo.git@[a-f0-9]*|${repo,,} @ git+https://github.com/QuantStrategyLab/$repo.git@$RSHA|" constraints.txt || true
3234 done
35+ sed -i "s|quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@[a-f0-9]*|quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@$SHA|" constraints.txt
3336
34- - name : Commit and push updated pin
35- run : |
36- git config user.name "github-actions[bot]"
37- git config user.email "github-actions[bot]@users.noreply.github.com"
38- git add QPK_PIN
39- if git diff --cached --quiet; then
40- echo "QPK_PIN already up to date"
37+ if git diff --quiet; then
38+ echo "changed=false" >> "$GITHUB_OUTPUT"
4139 else
42- git commit -m "chore: update QPK_PIN to $SHA"
43- git push
40+ echo "changed=true" >> "$GITHUB_OUTPUT"
4441 fi
42+
43+ - name : Create PR for pin update
44+ if : steps.update.outputs.changed == 'true'
45+ uses : peter-evans/create-pull-request@v7
46+ with :
47+ commit-message : " chore: auto-update QPK_PIN and constraints.txt"
48+ title : " chore: auto-update QPK_PIN and constraints.txt"
49+ body : " Automated update of QPK_PIN and dependency constraint SHAs."
50+ branch : auto/qpk-pin-update
51+ delete-branch : true
0 commit comments