Add gh action #7
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: "test and deploy staging" | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
branches: | |
- master | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
name: unit test frontend and backend | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and tag backend image | |
id: build-image-backend | |
uses: docker/build-push-action@v4 | |
with: | |
file: Dockerfile.api | |
context: . | |
load: true | |
cache-from: type=gha,scope=backend | |
cache-to: type=gha,mode=max,scope=backend | |
- name: Run backend unit tests | |
run: | | |
docker run ${{ steps.build-image-backend.outputs.imageid }} python manage.py test | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: install frontend deps and run tests | |
env: | |
NODE_OPTIONS: "--max_old_space_size=4096" | |
run: | | |
cd ./ui | |
npm ci | |
npm run test:ci | |
- name: build frontend | |
run: | | |
npm run build:staging | |
- name: save build | |
uses: actions/upload-artifact@v4 | |
with: | |
name: frontend-build | |
path: ./ui/dist/ui | |
deploy: | |
runs-on: staging | |
name: deploy to staging | |
steps: | |
- name: activate env | |
working-directory: $vars.APP_LOCATION | |
run: conda activate .\venv\ | |
- name: showmigrations | |
working-directory: $vars.APP_LOCATION | |
run: python manage.py showmigrations | |