-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (52 loc) · 1.41 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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