-
Notifications
You must be signed in to change notification settings - Fork 0
38 lines (30 loc) · 1.03 KB
/
backend-cd.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
name: Backend AWS EC2 CD
on:
workflow_run:
workflows: ["Backend Docker Image CI"]
types:
- completed
jobs:
build:
runs-on: [self-hosted, backend]
steps:
- name: Login to Dockerhub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Pull the Docker image
run: docker pull nathan7934/whosaidit-backend:latest
# Check out the repository so we can access the docker-compose.prod.yml file
- uses: actions/checkout@v3
with:
ref: master
# Create a .env file with the necessary environment variables in the runner's workspace
- name: Create .env file
run: |
echo "${{ secrets.BACKEND_ENV_VARS }}" > ./backend/.env
# Cycle the docker containers
- name: Stop current Docker containers
run: docker-compose -f ./backend/docker-compose.prod.yml down
- name: Start new Docker containers
run: docker-compose -f ./backend/docker-compose.prod.yml up -d