|
| 1 | +name: Changes In High Risk Code |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + |
| 5 | +# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value |
| 6 | +concurrency: |
| 7 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 8 | + cancel-in-progress: true |
| 9 | + |
| 10 | +jobs: |
| 11 | + files-changed: |
| 12 | + name: Detect changed files |
| 13 | + runs-on: ubuntu-latest |
| 14 | + # Map a step output to a job output |
| 15 | + outputs: |
| 16 | + high_risk_code: ${{ steps.changes.outputs.high_risk_code }} |
| 17 | + high_risk_code_files: ${{ steps.changes.outputs.high_risk_code_files }} |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + - name: Get changed files |
| 21 | + id: changes |
| 22 | + uses: getsentry/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1 |
| 23 | + with: |
| 24 | + token: ${{ github.token }} |
| 25 | + filters: .github/file-filters.yml |
| 26 | + |
| 27 | + # Enable listing of files matching each filter. |
| 28 | + # Paths to files will be available in `${FILTER_NAME}_files` output variable. |
| 29 | + list-files: csv |
| 30 | + |
| 31 | + validate-high-risk-code: |
| 32 | + if: needs.files-changed.outputs.high_risk_code == 'true' |
| 33 | + needs: files-changed |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - name: Comment on PR to notify of changes in high risk files |
| 37 | + uses: actions/github-script@v7 |
| 38 | + env: |
| 39 | + high_risk_code: ${{ needs.files-changed.outputs.high_risk_code_files }} |
| 40 | + with: |
| 41 | + script: | |
| 42 | + const highRiskFiles = process.env.high_risk_code; |
| 43 | + const fileList = highRiskFiles.split(',').map(file => `- [ ] ${file}`).join('\n'); |
| 44 | + github.rest.issues.createComment({ |
| 45 | + issue_number: context.issue.number, |
| 46 | + owner: context.repo.owner, |
| 47 | + repo: context.repo.repo, |
| 48 | + body: `### 🚨 Detected changes in high risk code 🚨 \n High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:\n ${fileList}` |
| 49 | + }) |
| 50 | + |
| 51 | + |
0 commit comments