remove msw and next-test-api-route-handler as dependencies #77
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] | |
jobs: | |
test: | |
name: Test code base | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install packages | |
run: npm install | |
- name: Lint | |
run: npm run lint | |
- name: Setup database | |
env: | |
DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
run: | | |
npm run prisma:migrate:deploy | |
- name: Unit Tests (Jest, React Test Library and Mock Service Worker UI tests) | |
run: npm run test:ui | |
# - name: API Integration Tests (Jest and next-test-api-route-handler API tests) | |
# env: | |
# DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
# run: npm run test:api | |
- name: create .env | |
run: | | |
touch .env.test.local | |
echo CYPRESS_baseUrl=${{ secrets.NEXTAUTH_URL }} >> .env.test.local | |
echo DATABASE_URL=${{ secrets.DATABASE_URL }} >> .env.test.local | |
echo NODE_ENV='test' >> .env.test.local | |
echo REVALIDATION_SECRET=${{ secrets.REVALIDATION_SECRET }} >> .env.test.local | |
echo APP_ENV='test' >> .env.test.local | |
echo NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} >> .env.test.local | |
echo NEXTAUTH_URL=${{ secrets.NEXTAUTH_URL }} >> .env.test.local | |
echo NEXT_PUBLIC_BASE_URL=${{ secrets.NEXT_PUBLIC_BASE_URL }} >> .env.test.local | |
echo TEST_USER_EMAIL=${{ secrets.TEST_USER_EMAIL }} >> .env.test.local | |
echo TEST_USER_PASSWORD=${{ secrets.TEST_USER_PASSWORD }} >> .env.test.local | |
- name: Cypress API, integration and E2E tests | |
uses: cypress-io/github-action@v6 | |
with: | |
build: npm run build:test | |
start: npm run cypress:start #npm run cypress:run | |
wait-on: http://localhost:3000 | |
config: baseUrl=http://localhost:3000 | |
wait-on-timeout: 120 | |
env: | |
DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
REVALIDATION_SECRET: ${{ secrets.REVALIDATION_SECRET }} | |
TEST_USER_EMAIL: ${{ secrets.TEST_USER_EMAIL }} | |
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }} | |
# npm run cypress:run | |
docker: | |
name: Docker Build, Tag and Push | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: create production .env | |
run: | | |
touch .env.production.local | |
echo DATABASE_URL=${{ secrets.PROD_DATABASE_URL }} >> .env.production.local | |
echo NEXTAUTH_SECRET=${{ secrets.PROD_NEXTAUTH_SECRET }} >> .env.production.local | |
echo NEXTAUTH_URL=${{ secrets.PROD_NEXTAUTH_URL }} >> .env.production.local | |
echo NEXT_PUBLIC_BASE_URL=${{ secrets.PROD_NEXT_PUBLIC_BASE_URL }} >> .env.production.local | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Docker Build | |
run: docker-compose build # --no-cache #docker compose up --build --force-recreate | |
- name: Docker Tag | |
run: docker tag 168-hours-nextjs-docker:latest jarrodlilkendey/168-hours-nextjs-docker:latest | |
# env: | |
# DATABASE_URL: ${{ secrets.PROD_DATABASE_URL }} | |
# NEXTAUTH_SECRET: ${{ secrets.PROD_NEXTAUTH_SECRET }} | |
# NEXTAUTH_URL: ${{ secrets.PROD_NEXTAUTH_URL }} | |
# NEXT_PUBLIC_BASE_URL: ${{ secrets.PROD_NEXT_PUBLIC_BASE_URL }} | |
- name: Docker Push to Docker Hub | |
run: docker push jarrodlilkendey/168-hours-nextjs-docker:latest | |
deploy: | |
name: Deploy to Digital Ocean over SSH | |
needs: docker | |
runs-on: ubuntu-latest | |
steps: | |
- name: SSH | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ secrets.DIGITALOCEAN_IP }} | |
username: ${{ secrets.DIGITALOCEAN_SSH_USERNAME }} | |
key: ${{ secrets.DIGITALOCEAN_SSH_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
script_stop: true | |
debug: true | |
script: | | |
docker ps -a | |
docker compose down | |
docker pull jarrodlilkendey/168-hours-nextjs-docker:latest | |
docker compose up --build --force-recreate --detach --wait | |
docker ps -a |