Skip to content

Commit

Permalink
Use an unofficial netlify GH action to properly handle error states w…
Browse files Browse the repository at this point in the history
…hen publishing to CDN. Use a more descriptive deployment message. (#90)
  • Loading branch information
varoonp123 authored Aug 24, 2023
1 parent ca99588 commit 8f62032
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions .github/workflows/web_release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Web release -- Netlify
on:
# We will publish to the dev website on pushes to main, with the option of manually cutting a release to the prod website.
workflow_dispatch:
inputs:
deploymentAppTier:
Expand All @@ -10,16 +11,26 @@ on:
options:
- dev
- prod
push: # We will publish to the dev website on pushes to main
push:
branches:
- main
env:
RUST_BACKTRACE: 1
APP_TIER: "${{ ((github.event_name == 'workflow_dispatch') && (inputs.deploymentAppTier == 'prod')) && 'PROD' || 'DEV' }}"
jobs:
wasm-publish:
name: Build and publish WASM-based game to Netlify dev branch
name: Build and publish WASM-based game to Netlify
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Log App tier
id: start
run: |
set -euxo pipefail
echo "Publishing app tier: $APP_TIER"
echo "shortGitSha=${GITHUB_SHA:0:7}" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v3
- name: Install rust nightly toolchain
Expand All @@ -30,32 +41,24 @@ jobs:
run: |
set -euxo pipefail
sudo apt install -y lld g++ pkg-config libx11-dev libasound2-dev libudev-dev binaryen
shell: bash
- name: Build wasm assets
run: ./build_wasm.sh
- name: Publish test deployment to netlify dev site
if: "${{ !((github.event_name == 'workflow_dispatch') && (inputs.deploymentAppTier == 'prod')) }}"
uses: netlify/actions/cli@master
with:
# It says prod, but this just means that we publish to the 'actual dev site' and opt out of netlify's 'branch
# deploys'
args: 'deploy --prod --dir=out/ -m "Main branch preview deploy via GH Actions. Git sha: ${{ github.sha }}. Message: ${{ github.event.head_commit.message}}"'
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DEV_THETAWAVE_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
- name: Publish deployment to netlify prod site
if: "${{ (github.event_name == 'workflow_dispatch') && (inputs.deploymentAppTier == 'prod') }}"
uses: netlify/actions/cli@master
- name: Publish deployment to netlify website
id: publish
uses: jsmrcaga/action-netlify-deploy@v2.0.0
with:
args: 'deploy --prod --dir=out/ -m "Main branch deploy via GH Actions. Git sha: ${{ github.sha }}. Message: ${{ github.event.head_commit.message}}"'
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_PROD_THETAWAVE_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
ci-pass:
name: CI is green
runs-on: ubuntu-latest
needs:
- wasm-publish
steps:
- run: exit 0
NETLIFY_SITE_ID: ${{ (env.APP_TIER == 'PROD') && secrets.NETLIFY_PROD_THETAWAVE_SITE_ID || secrets.NETLIFY_DEV_THETAWAVE_SITE_ID }}
NETLIFY_DEPLOY_MESSAGE: >
Source: https://github.com/${{github.repository}}/tree/${{ steps.start.outputs.shortGitSha }}
Build: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
NETLIFY_DEPLOY_TO_PROD: true # This means we opt out of netlify's 'branch deployments' and manage app tiers via separate site ids
install_command: "echo Skipping installing the dependencies"
build_command: "echo Skipping building the web files"
build_directory: "out/"
- name: Finish CI
run: |
set -euxo pipefail
echo 'See the website at ${{ steps.publish.outputs.NETLIFY_LIVE_URL }} .'
echo 'Immutable site deployment URL : ${{ steps.publish.outputs.NETLIFY_PREVIEW_URL }} .'

0 comments on commit 8f62032

Please sign in to comment.