-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (38 loc) · 1.56 KB
/
run-shell-file.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
name: DICE FRONTEND CI/CD
on:
push:
branches:
- main
jobs:
DOCKER_BUILD_PUSH:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
run: |
docker buildx build --platform linux/arm64,linux/amd64 -t pinomaker/dice-frontend:latest-arm64 -t pinomaker/dice-frontend:latest-amd64 --file Dockerfile . --push
DOCKER_PULL_RUN:
runs-on: ubuntu-latest
needs: DOCKER_BUILD_PUSH
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Initialize Known Hosts
run: |
mkdir -p ~/.ssh
touch ~/.ssh/known_hosts
ssh-keyscan ${{ secrets.EC2_HOST_DEV }} >> ~/.ssh/known_hosts
- name: Set Permissions for Private Key
run: |
echo "${{ secrets.DEPLOY_SSH_KEY }}" > $HOME/key.pem
chmod 400 $HOME/key.pem
- name: Run Docker
env:
SSH_PEM_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
run: |
ssh -i $HOME/key.pem -o StrictHostKeyChecking=no ubuntu@${{ secrets.EC2_HOST_DEV }} "sudo docker container rm -f dice-frontend && sudo docker image rm pinomaker/dice-frontend:latest-amd64 && sudo docker pull pinomaker/dice-frontend:latest-amd64 && sudo docker run -d -p 8080:8080 --name dice-frontend pinomaker/dice-frontend:latest-amd64"