-
Notifications
You must be signed in to change notification settings - Fork 4
50 lines (41 loc) · 1.37 KB
/
main.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
name: Admin Deploy
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
deploy-frontend:
name: Deploy Admin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the Docker Image
run: docker build -t adminimage admin
- name: Save the Docker Image
run: docker save adminimage | gzip > adminimage.tar.gz
- name: Decrypt Key pair
run: gpg --batch --yes --decrypt --passphrase="$GPG_PASSWORD" --output FrontendServerKeyPair.pem ./secrets/FrontendServerKeyPair.pem.gpg
env:
GPG_PASSWORD: ${{ secrets.FRONTEND_GPG_PASSWORD }}
- name: chmod to Key Pair
run: chmod 400 FrontendServerKeyPair.pem
- name: Push Docker Image to AWS
uses: appleboy/scp-action@master
with:
host: ec2-3-17-180-100.us-east-2.compute.amazonaws.com
key_path: FrontendServerKeyPair.pem
username: ec2-user
source: adminimage.tar.gz
target: ~/app/
- name: Run Docker Container
uses: appleboy/ssh-action@master
with:
host: ec2-3-17-180-100.us-east-2.compute.amazonaws.com
username: ec2-user
key_path: FrontendServerKeyPair.pem
script_stop: true
script: |
cd ~/app
sudo docker load -i adminimage.tar.gz
sudo docker run -p 8080:80 -d adminimage