I just begin in the devops world and for my project, I have to realize a classic CI/CD pipeline using github actions. For my project, I made a simple website where a user can bet winning for some football games I entered in my DB.
My project uses MySQL for the database, Nodejs backend and Nextjs front end. I made a docker compose file to build everything together. Finally, I wrote some tests (only for the server for the moment). Here is the deal :
After I run docker-compose up locally, running 'npm test' runs my tests. The first test is to check the connection to the database. Everything works fine.
But now I want to do the same, but with the github actions, so I cannot push a commit if this doesn't pass my tests of course. However, on github, my first test (connection to the DB) never works, even if I run docker-compose before.
name: Docker Image CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the Docker images
working-directory: ./project
run: docker-compose build
- name: Run the docker compose
working-directory: ./project
run: docker-compose up -d
- name: install server dependencies
working-directory: ./project/server
run: npm ci
- name: run servers test
working-directory: ./project/server
run: npm test
- name: finish docker down
working-directory: ./project
run: docker-compose down
Also, and I think it has an important role of course, when I run all this locally, I have my '.env' file with mysql passwords etc.. and I don't understand how my app can get these information on github.