-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (90 loc) · 3.47 KB
/
deploy.yml
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Build and Deploy
on:
push:
branches:
- master
pull_request_target:
types: [opened, synchronize, reopened]
jobs:
native:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: recursive
- name: Add base repo to git config
run: git remote add upstream ${{ github.event.pull_request.base.repo.html_url }}
if: startsWith(github.event_name, 'pull_request')
- uses: lukka/get-cmake@latest
- name: Run CMake+vcpkg to build packages.
uses: lukka/run-cmake@v10
with:
configurePreset: 'ninja-multi-vcpkg'
buildPreset: 'ninja-multi-vcpkg-release'
web:
runs-on: ubuntu-latest
env:
EMSDK: '/tmp/emsdk'
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: recursive
- name: Add base repo to git config
run: git remote add upstream ${{ github.event.pull_request.base.repo.html_url }}
if: startsWith(github.event_name, 'pull_request')
- name: Setup Emscripten
run: |
git clone https://github.com/emscripten-core/emsdk.git ${EMSDK}
cd ${EMSDK}
./emsdk install latest
./emsdk activate latest
- uses: lukka/get-cmake@latest
- name: Run CMake+vcpkg to build packages.
uses: lukka/run-cmake@v10
with:
configurePreset: 'emscripten-vcpkg'
buildPreset: 'emscripten-vcpkg-debug'
- name: Prepare for web deploy
run: |
mv cmake-build-presets/emscripten-vcpkg/Debug/openblack-imgui-prototype.html cmake-build-presets/emscripten-vcpkg/Debug/index.html
cp main.cpp cmake-build-presets/emscripten-vcpkg/Debug
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./cmake-build-presets/emscripten-vcpkg/Debug
publish_branch: gh-pages
destination_dir: ${{ startsWith(github.event_name, 'pull_request') && format('pr/{0}', github.event.pull_request.number) || '' }}
- name: Comment PR
if: github.event_name == 'pull_request_target'
uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const url = `https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr/${{ github.event.pull_request.number }}`
const message = `🚀 PR was deployed in preview environment: [Open app](${url})`
const comments = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const botComment = comments.data.find(comment => comment.user.login === 'github-actions[bot]');
if (botComment) {
await github.rest.issues.updateComment({
comment_id: botComment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: message,
});
} else {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message,
});
}