Skip to content

made docker step dependent on test step #25

made docker step dependent on test step

made docker step dependent on test step #25

Workflow file for this run

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 run
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: create production .env
run: |
touch .env.production.local
echo CYPRESS_baseUrl=${{ secrets.PROD_NEXTAUTH_URL }} >> .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 #docker compose up --build --force-recreate
- name: Docker Push to Docker Hub
run: docker push jarrodlilkendey/168-hours-nextjs-docker:latest