Skip to content

Commit

Permalink
Add workflow to publish web assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
bwrsandman committed Aug 4, 2023
1 parent 61c4235 commit df8c2f3
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
103 changes: 103 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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,
});
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Black & White style ImGui Theme prototype
===

[Try it live](https://openblack.github.io/openblack-imgui-prototype)

0 comments on commit df8c2f3

Please sign in to comment.