-
Notifications
You must be signed in to change notification settings - Fork 10
45 lines (40 loc) · 1.26 KB
/
AutoNav_CI.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
name: AutoNav_CI
on:
push:
branches: [ "autonav_web" ]
workflow_dispatch:
jobs:
CI_Pipeline:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v3.1.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v5.3.0
with:
context: .
file: react.Dockerfile
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/autonav:react
CD_Pipeline:
name: Pull Docker image to EC2 and Run
runs-on: ubuntu-latest
needs: CI_Pipeline
steps:
- name: Deploy to EC2 instance
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
script: |
docker stop react || true
docker rm react || true
docker pull ${{ secrets.DOCKER_USERNAME }}/autonav:react
docker run -d --name react -p 80:80 ${{ secrets.DOCKER_USERNAME }}/autonav:react