-
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.
add action for auto publish to pages
- Loading branch information
Showing
4 changed files
with
85 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,17 @@ | ||
name: A workflow to build wasm for github pages | ||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
build: | ||
name: Wasm build/deploy action | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
uses: actions/checkout@v1 | ||
- | ||
uses: ./wasm-action | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,15 @@ | ||
FROM golang | ||
|
||
RUN go get -d github.com/strosel/treman | ||
RUN go get gioui.org/cmd/gogio | ||
|
||
RUN apt-get update | ||
RUN apt-get install --yes \ | ||
libxkbcommon-x11-dev \ | ||
libgles2-mesa-dev \ | ||
curl \ | ||
jq | ||
|
||
ADD entrypoint.sh /entrypoint.sh | ||
RUN chmod +x /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
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,11 @@ | ||
name: "Build + Publish wasm version" | ||
description: "Build wasm and publish to github pages" | ||
author: "[email protected]" | ||
|
||
runs: | ||
using: "docker" | ||
image: "Dockerfile" | ||
|
||
branding: | ||
icon: "mic" | ||
color: "purple" |
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,42 @@ | ||
#!/bin/bash | ||
|
||
|
||
REPO="treman" | ||
GITHUB_PATH="strosel/${REPO}" | ||
API_URL="https://api.github.com/repos/${GITHUB_PATH}" | ||
|
||
gogio -target js -o $REPO github.com/$GITHUB_PATH | ||
|
||
SHA=$(curl -X GET \ | ||
"${API_URL}/git/trees/pages" | \ | ||
jq '.tree | map(select(.path == "main.wasm")) | .[0]? | .sha') | ||
|
||
echo "{ \ | ||
\"message\": \"new release\",\ | ||
\"branch\": \"pages\",\ | ||
\"content\": \"$(openssl base64 -A -in ./$REPO/main.wasm)\",\ | ||
\"sha\": ${SHA} | ||
}" > data.txt | ||
|
||
tmp=$(mktemp) | ||
|
||
RES=$(curl \ | ||
-X PUT \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
-H "Authorization: token ${GITHUB_TOKEN}" \ | ||
-d @data.txt \ | ||
--write-out "%{http_code}" \ | ||
--output $tmp \ | ||
"${API_URL}/contents/main.wasm") | ||
|
||
if [ "$?" -ne 0 ]; then | ||
echo "Curl error" | ||
cat $tmp | ||
exit 1 | ||
fi | ||
|
||
if [ $RES -ne 200 ]; then | ||
echo "HTTP error ${RES}" | ||
cat $tmp | ||
exit 1 | ||
fi |