|
87 | 87 | - name: Run linting validation
|
88 | 88 | run: |
|
89 | 89 | ci-scripts/validate-lint.sh
|
| 90 | + check_peer_dependencies: |
| 91 | + name: CI - Check peerDependencies |
| 92 | + runs-on: ubuntu-latest |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@v4 |
| 95 | + with: |
| 96 | + fetch-depth: 0 |
| 97 | + - name: Setup node |
| 98 | + uses: actions/setup-node@v4 |
| 99 | + with: |
| 100 | + node-version: ${{ env.NODE_VERSION }} |
| 101 | + - name: Run peerDependencies check |
| 102 | + run: | |
| 103 | + bash ci-scripts/check-peer-deps.sh ${{ github.event.pull_request.base.ref }} |
| 104 | + - name: Collect peer dependency changes |
| 105 | + id: collect-peer-deps |
| 106 | + run: | |
| 107 | + if [ -s peer-deps-result.txt ]; then |
| 108 | + echo "output<<EOF" >> $GITHUB_OUTPUT |
| 109 | + echo "### ❗ peerDependencies changes detected:" >> $GITHUB_OUTPUT |
| 110 | + cat peer-deps-result.txt >> $GITHUB_OUTPUT |
| 111 | + echo "EOF" >> $GITHUB_OUTPUT |
| 112 | + else |
| 113 | + echo "output=No peerDependencies changes detected" >> $GITHUB_OUTPUT |
| 114 | + fi |
| 115 | + - name: Post PR comment if peerDependencies changed |
| 116 | + if: failure() && github.event.pull_request |
| 117 | + uses: actions/github-script@v7 |
| 118 | + with: |
| 119 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 120 | + script: | |
| 121 | + const fs = require('fs'); |
| 122 | + const path = 'peer-deps-result.txt'; |
| 123 | +
|
| 124 | + if (!fs.existsSync(path)) { |
| 125 | + console.log("No peer-deps result file found. Skipping comment."); |
| 126 | + return; |
| 127 | + } |
| 128 | +
|
| 129 | + const diff = fs.readFileSync(path, 'utf8').trim(); |
| 130 | + if (!diff) { |
| 131 | + console.log("peer-deps result file is empty. Skipping comment."); |
| 132 | + return; |
| 133 | + } |
| 134 | +
|
| 135 | + const issue_number = context.payload.pull_request.number; |
| 136 | + const owner = context.repo.owner; |
| 137 | + const repo = context.repo.repo; |
| 138 | + const botUser = context.actor; |
| 139 | +
|
| 140 | + const commentHeader = "🚨 **PeerDependencies Change Detected** 🚨"; |
| 141 | +
|
| 142 | + const body = ` |
| 143 | + ${commentHeader} |
| 144 | +
|
| 145 | + Your pull request includes modifications to \`peerDependencies\` in the following file(s): |
| 146 | +
|
| 147 | + \`\`\`diff |
| 148 | + ${diff} |
| 149 | + \`\`\` |
| 150 | +
|
| 151 | + Please note: Changes to peerDependencies are **restricted** and only permitted during **framework update releases**, as they may introduce breaking changes for customer's applications. |
| 152 | + If you believe this change is necessary, please reach out to the Asterix team for further assistance. |
| 153 | + `; |
| 154 | +
|
| 155 | + await github.rest.issues.createComment({ |
| 156 | + issue_number, |
| 157 | + owner, |
| 158 | + repo, |
| 159 | + body |
| 160 | + }); |
| 161 | +
|
90 | 162 | ci_result:
|
91 |
| - needs: [unit_tests, sonarqube_scan, linting] |
| 163 | + needs: [unit_tests, sonarqube_scan, linting, check_peer_dependencies] |
92 | 164 | name: CI - Result
|
93 | 165 | runs-on: ubuntu-latest
|
94 | 166 | if: ${{ always() }}
|
|
0 commit comments