Updated workflows #6
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/CD Pipeline | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
services: | |
mongo: | |
image: mongo:latest | |
ports: | |
- 27017:27017 | |
redis: | |
image: redis:latest | |
ports: | |
- 6379:6379 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
# Install Docker Compose | |
- name: Install Docker Compose | |
run: | | |
sudo apt-get update | |
sudo apt-get install docker-compose -y | |
- name: Build and push Docker images | |
run: | | |
docker-compose -f ./docker-compose.yml build | |
docker-compose -f ./docker-compose.yml push | |
- name: Start Docker Compose services | |
run: docker-compose -f ./docker-compose.yml up -d | |
- name: Run tests | |
run: | | |
# Testing CI/CD | |
echo "Running tests..." | |
- name: Stop Docker Compose services | |
if: always() | |
run: docker-compose -f ./docker-compose.yml down |