Skip to content

Commit 0e035ef

Browse files
Merge pull request #134 from MarcelDiessner/feature/syntaxChecking
Patch Feature/syntax checking
2 parents 65f071a + df3890b commit 0e035ef

2 files changed

Lines changed: 37 additions & 17 deletions

File tree

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
name: Check PR Katacoda Syntax
2-
2+
env:
3+
PR_NUMBER: ${{github.event.number}}
34
on:
45
pull_request_target:
56
branches: [ main ]
67
jobs:
78
setup-matrix:
89
runs-on: ubuntu-latest
9-
env:
10-
PR_NUMBER: ${{github.event.number}}
1110

1211
steps:
1312
- name: Checkout playbooks
@@ -18,8 +17,10 @@ jobs:
1817
run: npm install
1918
- name: Select Changed Files
2019
id: changedfiles
21-
run: |
22-
node selectChangedFiles.js
20+
run: node selectChangedFiles.js
21+
- name: Get branch
22+
id: get_branch
23+
run: node getHeadRef.js
2324
- name: Setup matrix combinations
2425
id: setup-matrix-combinations
2526
run: |
@@ -34,6 +35,7 @@ jobs:
3435
echo ::set-output name=matrix-combinations::{\"include\":[$MATRIX_PARAMS_COMBINATIONS]}
3536
outputs:
3637
matrix-combinations: ${{ steps.setup-matrix-combinations.outputs.matrix-combinations }}
38+
head_ref: ${{ steps.get_branch.outputs.head_ref}}
3739

3840
build:
3941
runs-on: ubuntu-latest
@@ -45,31 +47,24 @@ jobs:
4547
uses: actions/checkout@v2
4648
with:
4749
repository: devonfw-tutorials/tutorial-compiler
48-
4950
- name: Checkout playbooks
5051
uses: actions/checkout@v2
5152
with:
5253
repository: devonfw-tutorials/tutorials
54+
ref: ${{needs.setup-matrix.outputs.head_ref}}
5355
path: playbooks
54-
5556
- uses: actions/setup-node@v2-beta
56-
5757
- name: install TS
5858
run: npm install typescript
59-
6059
- name: npm install
6160
run: npm install
62-
63-
- name: run buildRun.sh --user ${{ github.actor }} --branch ${{ github.event.pull_request_target.head.ref }} --checkSyntax
64-
run: |
65-
sh buildRun.sh --user ${{ github.actor }} --branch ${{ github.event.pull_request_target.head.ref }} --checkSyntax -p ${{ matrix.tutorial }} -e test_console
66-
61+
- name: run buildRun.sh --user ${{ github.actor }} --branch ${{needs.setup-matrix.outputs.head_ref}} --checkSyntax
62+
run: sh buildRun.sh --user ${{ github.actor }} --branch ${{needs.setup-matrix.outputs.head_ref}} --checkSyntax -p ${{ matrix.tutorial }} -e test_console
6763
- name: Check error file existence
6864
id: check_files
6965
uses: andstor/file-existence-action@v1
7066
with:
7167
files: "./build/errors/syntaxErrors.md"
72-
7368
- name: Get message
7469
id: get_message
7570
if: steps.check_files.outputs.files_exists == 'true'
@@ -80,11 +75,10 @@ jobs:
8075
message="${message//$'\r'/'%0D'}"
8176
echo "${message}"
8277
echo "::set-output name=message::$message"
83-
8478
- name: Request changes
8579
if: ${{ steps.get_message.outputs.message != '' }}
8680
uses: andrewmusgrave/automatic-pull-request-review@0.0.2
8781
with:
8882
repo-token: '${{ secrets.GITHUB_TOKEN }}'
8983
event: COMMENT
90-
body: ${{ steps.get_message.outputs.message }}
84+
body: ${{ steps.get_message.outputs.message }}

getHeadRef.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const core = require("@actions/core");
2+
const { Octokit } = require("@octokit/core");
3+
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
4+
5+
async function getHeadRef() {
6+
let pr = process.env.PR_NUMBER;
7+
let ref ="";
8+
try {
9+
let get = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}', {
10+
owner: 'devonfw-tutorials',
11+
repo: 'tutorials',
12+
pull_number: pr
13+
});
14+
ref = get.data.head.ref;
15+
} catch(e) {
16+
throw e;
17+
}
18+
core.info(`Head Ref: ${ref}`);
19+
core.setOutput('head_ref', ref);
20+
}
21+
22+
getHeadRef().catch(err => {
23+
console.log(err);
24+
process.exit(1);
25+
});
26+

0 commit comments

Comments
 (0)