Repository navigation
69 lines (64 loc) · 2.42 KB
/
Copy pathtrigger-seed.yaml
File metadata and controls
69 lines (64 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Trigger seed in tackle2-hub
on:
push:
branches:
- main
- 'release-*'
jobs:
filter:
runs-on: ubuntu-latest
outputs:
rules_changed: ${{ steps.filter.outputs.rules_changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
rules_changed:
- 'stable/**/*.yaml'
- '!**/*.test.yaml'
trigger-seed:
needs: filter
if: needs.filter.outputs.rules_changed == 'true'
runs-on: ubuntu-latest
steps:
- name: Get Token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v4
with:
application_id: ${{ vars.KONVEYOR_BOT_ID }}
application_private_key: ${{ secrets.KONVEYOR_BOT_KEY }}
# Permission needed to send repository_dispatch
permissions: "contents:write"
revoke_token: true
- name: Dispatch event to create seed PR
uses: actions/github-script@v7
with:
github-token: ${{ steps.get_workflow_token.outputs.token }}
script: |
const { owner, repo } = context.repo;
const repoUrl = context.payload.repository.html_url;
const fullMessage = (context.payload.head_commit || {}).message || '';
// The merged rulesets PR title is the first line of the merge/squash commit message.
const commitSubject = fullMessage.split('\n')[0];
// Resolve the merged PR number: squash merges end with "(#123)";
// merge commits start with "Merge pull request #123".
const match = fullMessage.match(/\(#(\d+)\)/) || fullMessage.match(/#(\d+)/);
const prNumber = match ? parseInt(match[1], 10) : null;
const payload = {
branch: context.ref.replace('refs/heads/', ''),
repo: `${owner}/${repo}`,
commit_subject: commitSubject,
pr_number: prNumber,
pr_url: prNumber ? `${repoUrl}/pull/${prNumber}` : '',
};
core.info(`Dispatching trigger-seed to konveyor/tackle2-seed:\n${JSON.stringify(payload, null, 2)}`);
await github.rest.repos.createDispatchEvent({
owner: 'konveyor',
repo: 'tackle2-seed',
event_type: 'trigger-seed',
client_payload: payload,
});