aboutsummaryrefslogtreecommitdiffstats
path: root/.github
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2022-02-09 21:57:50 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2022-02-10 12:57:58 +0200
commit68d8bce98b016b440ac648123b8d40b49244ed7f (patch)
tree3d2201000fcdb785effbd98ad3d136f61c366287 /.github
parentd989e1e942a77749c31e82296dd6c83a97184fd0 (diff)
Add CI
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/job.yml59
1 files changed, 59 insertions, 0 deletions
diff --git a/.github/workflows/job.yml b/.github/workflows/job.yml
new file mode 100644
index 0000000..c4f7f81
--- /dev/null
+++ b/.github/workflows/job.yml
@@ -0,0 +1,59 @@
+name: Test, build and publish UI
+on:
+ push:
+ branches:
+ - main
+env:
+ GCS_BUCKET: slam-lang-gh-artifacts
+ VITE_RUNNER_API_URL: https://runner-api-6hdcd6nxsq-ew.a.run.app
+ VITE_EXAMPLE_API_URL: https://example-api-6hdcd6nxsq-ew.a.run.app
+
+jobs:
+ test-build-and-publish:
+ runs-on: ubuntu-latest
+ steps:
+ - id: checkout
+ uses: actions/checkout@v2
+
+ - name: "Compute archive name"
+ run: |
+ echo "Long commit SHA: ${GITHUB_SHA}"
+ export TAG=$(echo "${GITHUB_SHA}" | head -c 7)
+ export ARCHIVE="ui-${TAG}.zip"
+ echo "ARCHIVE: ${ARCHIVE}"
+ echo "TAG=${TAG}" >> ${GITHUB_ENV}
+ echo "ARCHIVE=${ARCHIVE}" >> ${GITHUB_ENV}
+
+ - id: "auth"
+ uses: "google-github-actions/auth@v0"
+ with:
+ credentials_json: "${{ secrets.GCP_CREDENTIALS }}"
+
+ - name: "Set up Node.js 16"
+ uses: actions/setup-node@v2
+ with:
+ node-version: "16"
+
+ - name: "Set up Cloud SDK"
+ uses: "google-github-actions/setup-gcloud@v0"
+
+ - name: "Install NPM deps"
+ run: |
+ npm ci
+ npm i serve
+
+ - name: "Build"
+ run: |
+ npm run build
+
+ - name: "Run E2E tests"
+ run: |
+ npx -y serve -p 3000 dist &
+ npm run test
+ kill %1
+
+ - name: "Compress and publish"
+ run: |
+ zip -r "${ARCHIVE}" dist
+ gsutil cp "${ARCHIVE}" gs://${GCS_BUCKET}/
+ echo "Published revision ${TAG} (archive gs://${GCS_BUCKET}/${ARCHIVE})"