May 2024 update to production #13
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 react app and deploy to production" | |
on: | |
push: | |
branches: | |
- production | |
paths: | |
- .github/workflows/react-prod.yml | |
- react/**/* | |
pull_request: | |
branches: | |
- production | |
paths: | |
- .github/workflows/react-prod.yml | |
- react/**/* | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: "Log level" | |
required: true | |
default: "warning" | |
type: choice | |
options: | |
- info | |
- warning | |
- debug | |
jobs: | |
build-react: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
working-directory: react | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT" | |
- uses: actions/cache@v4 | |
id: yarn-cache | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: install dependencies | |
run: yarn install | |
- name: run eslint | |
run: | | |
yarn lint | |
- name: run prettier | |
run: | | |
yarn check-format | |
- name: compile typescript | |
run: | | |
yarn tsc | |
deploy-production: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
working-directory: react | |
needs: build-react | |
environment: OSMP_PROD | |
concurrency: OSMP_PROD | |
if: github.ref == 'refs/heads/production' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
- name: Get yarn cache path | |
id: yarn-cache-path | |
run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT" | |
- uses: actions/cache@v4 | |
id: restore | |
with: | |
path: | | |
${{ steps.yarn-cache-path.outputs.dir }} | |
react/node_modules | |
key: ${{ runner.os }}-yarn-${{ hashFiles('react/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- run: yarn install # should never happen due to build job | |
if: steps.restore.outputs.cache-hit != 'true' | |
# End setup | |
- run: yarn build | |
env: | |
REACT_APP_GRAPHQL_URL: ${{ secrets.REACT_APP_GRAPHQL_URL }} | |
REACT_APP_KEYCLOAK_AUTH_URL: ${{ secrets.REACT_APP_KEYCLOAK_AUTH_URL }} | |
REACT_APP_KEYCLOAK_REALM: ${{ secrets.REACT_APP_KEYCLOAK_REALM }} | |
REACT_APP_KEYCLOAK_CLIENT_ID: ${{ secrets.REACT_APP_KEYCLOAK_CLIENT_ID }} | |
REACT_APP_SOURCE_LIST: ${{ secrets.REACT_APP_SOURCE_LIST }} | |
- name: Upload to Minio bucket | |
env: | |
MC_HOST_minio: ${{ secrets.MC_HOST }} | |
run: | | |
sudo curl --output /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc | |
sudo chmod +x /usr/local/bin/mc | |
./deploy.sh minio ${{ secrets.MINIO_BUCKET }} |