forked from emilk/egui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4ed394
commit 79f37f4
Showing
3 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# This action builds and deploys egui_demo_app on each pull request created | ||
# Security notes: | ||
# This action is split in two workflows, preview_build and preview_deploy. | ||
# `preview_build` runs on pull_request, so it won't have any access to the repositories secrets, so it is safe to execute | ||
# untrusted code. | ||
# `preview_deploy` has access to the repositories secrets (so it can push to the pr preview repo) but won't run | ||
# any untrusted code (it will just extract the build artifact and push it to the pages branch where it will | ||
# automatically be deployed). | ||
|
||
on: | ||
- pull_request | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: rustup toolchain install stable --profile minimal --target wasm32-unknown-unknown | ||
- uses: Swatinem/rust-cache@v2 | ||
with: | ||
prefix-key: "pr-preview-" | ||
|
||
- name: "Install wasmopt / binaryen" | ||
run: | | ||
sudo apt-get update && sudo apt-get install binaryen | ||
- run: | | ||
scripts/build_demo_web.sh --release | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: web_demo | ||
path: web_demo | ||
|
||
- name: Generate meta.json | ||
env: | ||
PR_NUMBER: ${{ github.event.number }} | ||
PR_BRANCH: ${{ github.head_ref }} | ||
run: | | ||
echo "{\"pr_number\": \"$PR_NUMBER\", \"pr_branch\": \"$PR_BRANCH\"}" > meta.json | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: meta.json | ||
path: meta.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
on: | ||
pull_request_target: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
cleanup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: mkdir -p empty_dir | ||
- name: Url slug variable | ||
run: | | ||
echo "URL_SLUG=${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV | ||
- name: Deploy | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
if: secrets.DEPLOY_KEY | ||
with: | ||
folder: empty_dir | ||
repository-name: egui-pr-preview/pr | ||
branch: 'main' | ||
clean: true | ||
target-folder: ${{ env.URL_SLUG }} | ||
ssh-key: ${{ secrets.DEPLOY_KEY }} | ||
commit-message: "Remove preview for PR ${{ env.URL_SLUG }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
on: | ||
workflow_run: | ||
workflows: | ||
- preview_build | ||
types: | ||
- completed | ||
|
||
|
||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download Artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
run-id: '${{ github.event.workflow_run.id }}' | ||
|
||
- name: Parse meta.json | ||
run: | | ||
echo "PR_NUMBER=$(jq -r .pr_number meta.json)" >> $GITHUB_ENV | ||
echo "PR_BRANCH=$(jq -r .pr_branch meta.json)" >> $GITHUB_ENV | ||
- name: Url slug variable | ||
run: | | ||
echo "URL_SLUG=${{ env.PR_NUMBER }}-${{ env.PR_BRANCH }}" >> $GITHUB_ENV | ||
- name: Deploy | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
if: secrets.DEPLOY_KEY | ||
with: | ||
folder: web_demo | ||
repository-name: egui-pr-preview/pr | ||
branch: 'main' | ||
clean: true | ||
target-folder: ${{ env.URL_SLUG }} | ||
ssh-key: ${{ secrets.DEPLOY_KEY }} | ||
commit-message: "Update preview for PR ${{ env.URL_SLUG }}" | ||
force: false | ||
|
||
- name: Comment PR | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
message: | | ||
Preview available at https://egui-pr-preview.github.io/pr/${{ env.URL_SLUG }} |