Skip to content

Trying to fix pipepline #48

Trying to fix pipepline

Trying to fix pipepline #48

Workflow file for this run

name: Auto tests for EventEase
on: push
env:
PG_DATABASE: EventEase_database_test
PG_USER: postgres
PG_PASSWORD: ${{ secrets.DB_PWD }}
SECRET: ${{ secrets.SECRET }}
jobs:
run-tests:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11.7
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${{ secrets.DB_PWD }}
POSTGRES_DB: EventEase_database_test
SECRET: ${{ secrets.SECRET }}
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install dependencies
run: cd backend && npm ci
- name: Run unit tests
id: unit-tests
run: cd backend && npm test
- name: Run the app
id: run-app
run: |
cd backend
npm install
npx sequelize-cli db:drop
npx sequelize-cli db:create
npx sequelize-cli db:migrate
PORT=3000 npm start &
sleep 5
- name: Run integration tests
id: integration-tests
run: |
cd backend
npm install cypress cypress-json-results
npx cypress run
docker:
name: Docker image build
needs: [run-tests]
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login --username ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
- name: Build and Push Docker Image
run: |
cd backend
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/eventease:latest .
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/eventease:latest
deploy:
name: Auto deployment
needs: [docker]
runs-on: ubuntu-latest
steps:
- name: Backend deployment in Render
uses: johnbeynon/render-deploy-action@v0.0.8
with:
service-id: ${{ secrets.SERVICE_ID }}
api-key: ${{ secrets.EVENTEASE_API }}
notifications:
needs: [run-tests,docker,deploy]
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Notify Slack
env:
SLACK_WEBHOOK_URL: ${{ secrets.SECRET_NAME }}
run: |
if [[ ${{ needs.run-tests.result }} == 'success' && ${{ needs.deploy.result }} == 'success' && ${{ needs.docker.result }} == 'success' ]]; then
curl -X POST -H 'Content-type: application/json' --data '{"text":"Automated tests for EventEase completed successfully. \nCheck the logs for details: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"}' $SLACK_WEBHOOK_URL
else
curl -X POST -H 'Content-type: application/json' --data '{"text":"Automated tests for EventEase* failed.\nCheck the logs for details: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"}' $SLACK_WEBHOOK_URL
fi