Merge pull request #421 from ymyzk/dependabot/npm_and_yarn/app/fronte… #623
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: CI | |
on: [push] | |
env: | |
APP_IMAGE_NAME: ymyzk/mypy-playground | |
SANDBOX_IMAGE_NAME: ymyzk/mypy-playground-sandbox | |
DOCKER_BUILDKIT: 1 | |
jobs: | |
test_app: | |
name: Test app | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.11'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Upgrade packaging tools | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
python -m pip install tox-gh-actions | |
- name: Run tox | |
run: tox | |
working-directory: ./app | |
test_frontend: | |
name: Test frontend | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies | |
run: npm ci | |
working-directory: ./app/frontend | |
- name: Build, lint, and test frontend | |
run: | | |
npm run build | |
npm run lint | |
npm run test:ci | |
working-directory: ./app/frontend | |
build_docker_images: | |
name: Build and push Docker images | |
needs: | |
- test_app | |
- test_frontend | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- run: docker version | |
- name: Build app image for development | |
run: docker build --pull -t app:dev ./app | |
- name: Build app image for production | |
run: docker build --pull -t app:latest -f ./app/Dockerfile-prod ./app | |
- name: Build latest Docker sandbox image | |
if: github.ref != 'refs/heads/master' | |
run: docker build -t sandbox:latest ./sandbox/docker/latest | |
- name: Build Docker sandbox images | |
if: github.ref == 'refs/heads/master' | |
run: ./sandbox/docker/build.sh $SANDBOX_IMAGE_NAME | |
- name: Login to Docker Hub | |
if: github.ref == 'refs/heads/master' | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: Push app image | |
if: github.ref == 'refs/heads/master' | |
run: | | |
docker tag app:latest $APP_IMAGE_NAME:latest | |
docker push $APP_IMAGE_NAME:latest | |
- name: Push Docker sandbox images | |
if: github.ref == 'refs/heads/master' | |
run: ./sandbox/docker/push.sh $SANDBOX_IMAGE_NAME |