74 lines
2.7 KiB
YAML
74 lines
2.7 KiB
YAML
name: update-saas-frontend
|
|
|
|
# Edit with caution ! Made for build+test on "feature/*" push and pull requests events
|
|
# And for only deploying on pushes on "main" branch
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- "twake/frontend/**"
|
|
- "twake/docker/**"
|
|
- ".github/workflows/**"
|
|
pull_request:
|
|
branches: [main]
|
|
paths:
|
|
- "twake/frontend/**"
|
|
|
|
jobs:
|
|
build-frontend:
|
|
runs-on: ubuntu-20.04
|
|
env:
|
|
FRONTEND_ENV: ${{secrets.FRONTEND_ENV}}
|
|
|
|
strategy:
|
|
matrix:
|
|
node-version: [14.x]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@v1
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
- run: npm install -g yarn
|
|
- run: cd twake/frontend/ && yarn install
|
|
- run: cp twake/frontend/src/app/environment/environment.ts.dist twake/frontend/src/app/environment/environment.ts
|
|
- if: ${{env.FRONTEND_ENV}}
|
|
run: echo ${{ secrets.FRONTEND_ENV }} > twake/frontend/src/app/environment/environment.ts
|
|
- run: cd twake/frontend/ && yarn test
|
|
- run: cd twake/frontend/ && yarn build
|
|
- name: Upload frontend build artifact
|
|
uses: actions/upload-artifact@v1
|
|
with:
|
|
name: frontend-build
|
|
path: twake/frontend/build/
|
|
|
|
deploy-nginx:
|
|
needs: build-frontend
|
|
runs-on: ubuntu-20.04
|
|
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/qa' || github.ref == 'refs/heads/canary'
|
|
steps:
|
|
- run: 'echo "DOCKERTAGVERSION=2023.Q1.1223" >> $GITHUB_ENV'
|
|
- name: Set env to develop
|
|
if: endsWith(github.ref, '/develop')
|
|
run: 'echo "DOCKERTAG=develop" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=2023.Q1.1223" >> $GITHUB_ENV'
|
|
- name: Set env to develop
|
|
if: endsWith(github.ref, '/qa')
|
|
run: 'echo "DOCKERTAG=qa" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=2023.Q1.1223" >> $GITHUB_ENV'
|
|
- name: Set env to develop
|
|
if: endsWith(github.ref, '/canary')
|
|
run: 'echo "DOCKERTAG=canary" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=${{ env.DOCKERTAGVERSION }}-canary" >> $GITHUB_ENV'
|
|
- name: Set env to production
|
|
if: endsWith(github.ref, '/main')
|
|
run: 'echo "DOCKERTAG=latest" >> $GITHUB_ENV'
|
|
- uses: actions/checkout@v2
|
|
- name: Publish to Registry
|
|
uses: elgohr/Publish-Docker-Github-Action@master
|
|
with:
|
|
name: twaketech/twake-nginx
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
workdir: twake
|
|
buildoptions: "-t twaketech/twake-nginx -f docker/twake-nginx/Dockerfile"
|
|
tags: "${{ env.DOCKERTAG }},${{ env.DOCKERTAGVERSION }}"
|