Update .github/workflows/rill-ui.yml #28
Workflow file for this run
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
name: Build and Deploy Cloud UI to Netlify | |
on: | |
create: | |
push: | |
tags: | |
- "**" | |
branches: | |
- "main" | |
- "release**" | |
paths: | |
- ".github/workflows/rill-ui.yml" | |
- "web-admin/**" | |
- "web-common/**" | |
workflow_dispatch: | |
inputs: | |
env: | |
description: "Environment" | |
required: true | |
default: "stage" | |
type: choice | |
options: | |
- stage | |
- prod | |
- test | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
jobs: | |
build: | |
# https://github.com/orgs/community/discussions/54860 | |
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || ( github.event_name == 'create' && startsWith(github.ref_name, 'release') ) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up NodeJS | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Setup Env variables from Inputs | |
env: | |
ENV: ${{ inputs.env }} | |
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
run: |- | |
# if push is via tag, should be deployed to prod | |
# if push is to release branch, should be deployed to stage | |
# else go to test, workflow_dispatch can choose the environment. | |
echo "GITHUB_EVENT_NAME=$GITHUB_EVENT_NAME" | |
echo "GITHUB_REF_NAME=$GITHUB_REF_NAME"' | |
echo $($GITHUB_REF_NAME =~ "release.*") | |
if [[ ( $GITHUB_EVENT_NAME == "push" && $RELEASE == "true" ) || ( $GITHUB_EVENT_NAME == "workflow_dispatch" && $ENV == "prod" ) ]]; then | |
echo "Deploying to prod..." | |
echo "NETLIFY_SITE_ID=afb26917-7a60-47d9-81dc-c0babbb0d9a9" >> $GITHUB_ENV | |
echo "DOMAIN=rilldata.com" >> $GITHUB_ENV | |
else | |
if [[ ( $GITHUB_EVENT_NAME == "push" && $GITHUB_REF_NAME =~ "release.*" ) || ( $GITHUB_EVENT_NAME == "workflow_dispatch" && $ENV == "stage" ) ]]; then | |
echo "Deploying to stage..." | |
echo "NETLIFY_SITE_ID=e73ac785-882e-425a-8fc8-5432528bb374" >> $GITHUB_ENV | |
echo "DOMAIN=rilldata.io" >> $GITHUB_ENV | |
else | |
echo "Deploying to test..." | |
echo "NETLIFY_SITE_ID=ad7b8d67-9b24-4b2a-8985-1a80b7b0ab11" >> $GITHUB_ENV | |
echo "DOMAIN=rilldata.in" >> $GITHUB_ENV | |
fi | |
fi | |
- name: Build Cloud UI | |
run: |- | |
npm install | |
npm run build -w web-admin | |
env: | |
VITE_RILL_ADMIN_URL: https://admin.${{ env.DOMAIN }} | |
- name: Deploy Cloud UI to Netlify ui.${{ env.DOMAIN }} | |
uses: nwtgck/[email protected] | |
with: | |
publish-dir: ./web-admin/build | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
deploy-message: "Cloud-admin ${{ github.ref_name }} deployed to ui.${{ env.DOMAIN }}" | |
production-deploy: true | |
enable-pull-request-comment: false | |
enable-commit-comment: true | |
overwrites-pull-request-comment: true | |
netlify-config-path: ./netlify.toml | |
timeout-minutes: 1 |