|
10 | 10 | - 'docs/**' |
11 | 11 | - 'detection_rules/**' |
12 | 12 | - 'tests/**' |
| 13 | + - '**/*.md' |
13 | 14 | types: [opened, reopened, synchronize] |
14 | | - push: |
15 | | - branches: |
16 | | - - main |
17 | 15 |
|
18 | 16 | permissions: |
19 | | - contents: write |
20 | | - pull-requests: write |
| 17 | + contents: read |
| 18 | + pull-requests: read |
21 | 19 |
|
22 | 20 | jobs: |
23 | | - version_check: |
| 21 | + label_check: |
24 | 22 | runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: Ensure PR has Version Bump Label |
| 25 | + uses: actions/github-script@v6 |
| 26 | + with: |
| 27 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 28 | + script: | |
| 29 | + const labels = ['major', 'minor', 'patch']; |
| 30 | + const prLabels = context.payload.pull_request.labels.map(label => label.name); |
| 31 | + const hasVersionLabel = labels.some(label => prLabels.includes(label)); |
| 32 | + if (!hasVersionLabel) { |
| 33 | + throw new Error("PR must have one of the following labels: major, minor, or patch."); |
| 34 | + } |
25 | 35 |
|
| 36 | + version_check: |
| 37 | + needs: label_check |
| 38 | + runs-on: ubuntu-latest |
26 | 39 | steps: |
27 | 40 | - name: Checkout repository |
28 | 41 | uses: actions/checkout@v4 |
29 | 42 |
|
30 | | - - name: Check for changes in kql, kibana, hunting, and etc |
31 | | - id: check_changes |
| 43 | + - name: Check if core pyproject.toml was updated |
32 | 44 | run: | |
33 | | - CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E 'lib/kql|lib/kibana|detection_rules|tests|hunting|etc/' || echo "no-changes") |
34 | | - if [ "$CHANGED_FILES" != "no-changes" ]; then |
35 | | - echo "CHANGES_FOUND=true" >> $GITHUB_ENV |
36 | | - else |
37 | | - echo "CHANGES_FOUND=false" >> $GITHUB_ENV |
| 45 | + if ! git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^pyproject.toml$'; then |
| 46 | + echo "Code changes detected in core, but pyproject.toml was not updated." |
| 47 | + exit 1 |
38 | 48 | fi |
39 | 49 |
|
40 | | - - name: Fail if no version bump in pyproject.toml |
41 | | - if: env.CHANGES_FOUND == 'true' |
| 50 | + - name: Check if lib pyproject.toml files were updated |
42 | 51 | run: | |
43 | | - if ! git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep 'pyproject.toml'; then |
44 | | - echo "Code changes detected in core, but pyproject.toml was not updated." |
45 | | - exit 1 |
| 52 | + if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E 'lib/kql/|lib/kibana/'; then |
| 53 | + if ! git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E 'lib/kql/pyproject.toml|lib/kibana/pyproject.toml'; then |
| 54 | + echo "Changes detected in kql or kibana library, but respective pyproject.toml was not updated." |
| 55 | + exit 1 |
| 56 | + fi |
46 | 57 | fi |
47 | 58 |
|
48 | 59 | release_drafter: |
| 60 | + if: github.event.pull_request.merged == true && needs.version_check.conclusion == 'success' |
49 | 61 | needs: version_check |
50 | 62 | runs-on: ubuntu-latest |
51 | | - |
| 63 | + permissions: |
| 64 | + contents: write |
52 | 65 | steps: |
53 | 66 | - name: Checkout repository |
54 | 67 | uses: actions/checkout@v4 |
|
0 commit comments