-
Notifications
You must be signed in to change notification settings - Fork 0
29 lines (27 loc) · 889 Bytes
/
Copy pathmain.yml
File metadata and controls
29 lines (27 loc) · 889 Bytes
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
name: CICD
on:
push:
branches:
- deploy-to-ec2
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v3
- name: Login to Docker Hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker Image
run: docker build -t cliu232/networking-platform-cicd .
- name: Publish image to docker hub
run: docker push cliu232/networking-platform-cicd:latest
deploy:
needs: build
runs-on: aws-ec2
steps:
- name: Pull image from docker hub
run: docker pull cliu232/networking-platform-cicd:latest
- name: Delete Old Container
run: docker rm -f reactContainer
- name: Run docker container
run: docker run -d -p 3000:80 --name reactContainer cliu232/networking-platform-cicd:latest