|
5 | 5 | - labeled |
6 | 6 | - unlabeled |
7 | 7 |
|
8 | | -concurrency: |
9 | | - group: ${{ github.workflow }}-${{ github.event.pull_request.number }} |
10 | | - cancel-in-progress: true |
11 | | - |
12 | 8 | jobs: |
13 | 9 | on-merge: |
14 | 10 | name: 'Label and Backport' |
15 | 11 | runs-on: ubuntu-latest |
16 | | - if: github.event.pull_request.merged == true |
| 12 | + if: | |
| 13 | + github.event.pull_request.merged == true && |
| 14 | + (github.event.action == 'closed' || |
| 15 | + (github.event.action == 'labeled' && |
| 16 | + (github.event.label.name == 'backport:all-open' || |
| 17 | + github.event.label.name == 'backport:version')) || |
| 18 | + (github.event.action == 'unlabeled' && |
| 19 | + github.event.label.name == 'backport:skip' && |
| 20 | + (contains(github.event.pull_request.labels.*.name, 'backport:all-open') || |
| 21 | + contains(github.event.pull_request.labels.*.name, 'backport:version')))) |
17 | 22 | steps: |
18 | | - - run: "echo hello!" |
19 | | - - name: Check out versions.json |
20 | | - uses: actions/checkout@v5 |
21 | | - with: |
22 | | - repository: 'elastic/kibana' |
23 | | - ref: main |
24 | | - sparse-checkout: | |
25 | | - versions.json |
26 | | - - name: Check Event Qualifies |
27 | | - uses: actions/github-script@v7 |
28 | | - id: check_event |
29 | | - with: |
30 | | - result-encoding: string |
31 | | - script: | |
32 | | - let shouldRun = false; |
33 | | - const backportLabels = { skip: 'backport:skip', allOpen: 'backport:all-open', version: 'backport:version' }; |
34 | | - const { pull_request: pr, action } = context.payload; |
35 | | - const labels = pr.labels.map(l => l.name); |
36 | | - const validVersionLabels = require('./versions.json').versions |
37 | | - .map(v => v.version.split('.').slice(0,2).join('.')) |
38 | | - .map(v => RegExp(`^v${v}\.[0-9]{1,2}$`)); |
39 | | - const labelsWarrantBackport = labels.includes(backportLabels.allOpen) || ( |
40 | | - labels.includes(backportLabels.version) && |
41 | | - labels.some(label => validVersionLabels.some(v => v.test(label))) |
42 | | - ); |
43 | | -
|
44 | | - if (action === 'closed') { |
45 | | - core.info('PR was merged, proceeding'); |
46 | | - shouldRun = true; |
47 | | - } else if ((action === 'labeled' || action === 'unlabeled') && labelsWarrantBackport) { |
48 | | - core.info('labelling action warrants backport, proceeding'); |
49 | | - shouldRun = true; |
50 | | - } else { |
51 | | - core.info('event does not warrant backport action, skipping'); |
52 | | - shouldRun = false; |
53 | | - } |
54 | | -
|
55 | | - core.info(`Should run on-merge action: ${shouldRun}`); |
56 | | - return shouldRun.toString(); |
57 | | -
|
58 | 23 | - name: Checkout Actions |
59 | | - if: ${{ steps.check_event.outputs.result == 'true' }} |
60 | 24 | uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
61 | 25 | with: |
62 | 26 | repository: 'elastic/kibana-github-actions' |
|
65 | 29 | persist-credentials: false |
66 | 30 |
|
67 | 31 | - name: Install Actions |
68 | | - if: ${{ steps.check_event.outputs.result == 'true' }} |
69 | 32 | run: npm install --production --prefix ./actions |
70 | 33 |
|
71 | 34 | - name: Run On-Merge |
72 | | - if: ${{ steps.check_event.outputs.result == 'true' }} |
73 | 35 | uses: ./actions/on-merge |
74 | 36 | with: |
75 | 37 | github_token: ${{secrets.KIBANAMACHINE_TOKEN}} |
0 commit comments