Skip to content

Commit aec0637

Browse files
authored
Merge pull request #5 from coding-cpp/fix/4
add on pr workflow
2 parents c23053d + ba796b2 commit aec0637

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/pr.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: "Pull Request check"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
with:
19+
submodules: recursive
20+
fetch-depth: 1
21+
- name: Update and Install dependencies
22+
run: |
23+
sudo apt-get update
24+
sudo apt-get install -y cmake build-essential g++
25+
- name: Build
26+
id: build
27+
run: |
28+
mkdir build
29+
cd build
30+
cmake ..
31+
make
32+
- name: Post success comment
33+
if: ${{ success() }}
34+
uses: actions/github-script@v6
35+
with:
36+
script: |
37+
github.rest.issues.createComment({
38+
issue_number: context.issue.number,
39+
owner: context.repo.owner,
40+
repo: context.repo.repo,
41+
body: 'Build successful! 🎉'
42+
});
43+
- name: Post failure comment
44+
if: ${{ failure() }}
45+
uses: actions/github-script@v6
46+
with:
47+
script: |
48+
github.rest.issues.createComment({
49+
...context.repo,
50+
issue_number: context.issue.number,
51+
owner: context.repo.owner,
52+
repo: context.repo.repo,
53+
body: `Build failed! ❌\n\n\`\`\`\n${{ steps.build.outputs.stderr || 'Unknown error' }}\n\`\`\``
54+
});

0 commit comments

Comments
 (0)