Commit 9adfd48 1 parent cb98886 commit 9adfd48 Copy full SHA for 9adfd48
File tree 3 files changed +74
-5
lines changed
3 files changed +74
-5
lines changed Original file line number Diff line number Diff line change
1
+ ## Description
2
+
3
+ Fixes
4
+
5
+ ### Remote Refs
6
+
7
+ <!-- - REMOTE REFS START -->
8
+
9
+ premium: main
10
+
11
+ <!-- - REMOTE REFS END -->
Original file line number Diff line number Diff line change 4
4
pull_request :
5
5
types : [opened, synchronize]
6
6
7
- env :
8
- PREMIUM_REPO_REF : main
9
-
10
7
jobs :
11
8
php-lint-test :
12
9
name : " PHP: Lint, Test"
@@ -22,13 +19,17 @@ jobs:
22
19
with :
23
20
token : ${{ secrets.ACCESS_TOKEN_IR }}
24
21
22
+ - name : Remote refs
23
+ uses : ./actions/upstream-refs
24
+ id : remote-refs
25
+
25
26
- name : Checkout premium projects repo
26
27
uses : actions/checkout@v4
27
28
with :
28
29
path : premium
29
30
token : ${{ secrets.ACCESS_TOKEN_IR }}
30
31
repository : ${{ secrets.PREMIUM_PROJECTS_REPO }}
31
- ref : ${{ env.PREMIUM_REPO_REF }}
32
+ ref : ${{ fromJSON(steps.remote-refs.outputs.result).premium || 'main' }}
32
33
33
34
- name : Setup Environment
34
35
uses : ./actions/setup
@@ -72,13 +73,17 @@ jobs:
72
73
with :
73
74
token : ${{ secrets.ACCESS_TOKEN_IR }}
74
75
76
+ - name : Remote refs
77
+ uses : ./actions/upstream-refs
78
+ id : remote-refs
79
+
75
80
- name : Checkout premium projects repo
76
81
uses : actions/checkout@v4
77
82
with :
78
83
path : premium
79
84
token : ${{ secrets.ACCESS_TOKEN_IR }}
80
85
repository : ${{ secrets.PREMIUM_PROJECTS_REPO }}
81
- ref : ${{ env.PREMIUM_REPO_REF }}
86
+ ref : ${{ fromJSON(steps.remote-refs.outputs.result).premium || 'main' }}
82
87
83
88
- name : Setup Environment
84
89
uses : ./actions/setup
Original file line number Diff line number Diff line change
1
+ name : " Read the refs/branches to use for checking out upstream repos"
2
+ description : " Reads and outputs the refs/branches from PR description to use for checking out upstream repos."
3
+ author : " wpsocio"
4
+
5
+ outputs :
6
+ result :
7
+ description : " Refs JSON"
8
+ value : ${{ steps.details.outputs.result }}
9
+
10
+ runs :
11
+ using : " composite"
12
+ steps :
13
+ - name : Get details
14
+ uses : actions/github-script@v7
15
+ id : details
16
+ with :
17
+ script : |
18
+ const pr = await github.rest.pulls.get({
19
+ owner: context.repo.owner,
20
+ repo: context.repo.repo,
21
+ pull_number: context.payload.pull_request.number,
22
+ });
23
+
24
+ /**
25
+ * The comment has to be in this format
26
+ *
27
+ * <!--- REMOTE REFS START -->
28
+ * some/project/path: add/some-feature
29
+ * some/other/project/path: fix/some-bug
30
+ * <!--- REMOTE REFS END -->
31
+ */
32
+ const refsCommentRegex =
33
+ /<!--- REMOTE REFS START -->(?<content>.+)<!--- REMOTE REFS END -->/is;
34
+
35
+ const result = (pr.data.body || '').match(refsCommentRegex);
36
+
37
+ if (!result?.groups?.content) {
38
+ return {};
39
+ }
40
+
41
+ const refs = result.groups.content
42
+ .trim()
43
+ .split(/[\n\r]+/)
44
+ .filter((line) => line.trim())
45
+ .reduce((list, line) => {
46
+ const [name, ref] = line.split(/:\s?/);
47
+
48
+ list[name.trim()] = ref.trim();
49
+
50
+ return list;
51
+ }, {});
52
+
53
+ return refs;
You can’t perform that action at this time.
0 commit comments