-
Notifications
You must be signed in to change notification settings - Fork 2
82 lines (71 loc) · 2.6 KB
/
deploy.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Deploy to AWS
on:
push:
branches:
- dev
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: SSH into AWS EC2
env:
AWS_PRIVATE_KEY: ${{ secrets.AWS_PRIVATE_KEY }}
run: |
echo "$AWS_PRIVATE_KEY" > aws-key.pem
chmod 600 aws-key.pem
ssh -o StrictHostKeyChecking=no -i ./aws-key.pem [email protected]
ls
- name: Update and Install libssl-dev
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev
- name: Print libcrypto Version
run: |
openssl version
- name: Configure SSH
run: |
mkdir -p ~/.ssh
echo "$PRIVATE_REPO_SSH_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
env:
PRIVATE_REPO_SSH_KEY: ${{ secrets.PRIVATE_REPO_SSH_KEY }}
- name: Clone Private Repository
run: |
cd ..
ls
git clone [email protected]:alitpc25/cmpe451group1configrepo.git
cp -r cmpe451group1configrepo/project_env_prod ./resq/backend/resq/project_env_prod
# - name: Decrypt and Extract project_env_prod
# env:
# RESQ_PASSPHRASE: ${{ secrets.RESQ_PASSPHRASE }}
# run: |
# cd ./resq/backend/resq/
# gpg --quiet --batch --yes --verbose --decrypt --passphrase="$RESQ_PASSPHRASE" --output project_env_prod.tar.gz project_env_prod.tar.gz.gpg
# tar xzvf project_env_prod.tar.gz
- name: Set up Docker
uses: docker/[email protected]
with:
dockerfile: Dockerfile.remote
- name: Build and Push Docker Image
run: |
ls
cd ./resq/backend/resq/
docker build -t alitpc2525/resq:latest -f Dockerfile.remote .
docker login -u alitpc2525 -p ${{ secrets.DOCKER_PASSWORD }}
docker tag alitpc2525/resq:latest alitpc2525/resq:latest
docker push alitpc2525/resq:latest
- name: SSH into AWS EC2
uses: appleboy/[email protected]
with:
host: ${{ secrets.AWS_EC2_HOST }}
username: ec2-user
key: ${{ secrets.AWS_PRIVATE_KEY }}
script: |
sudo service docker start
sudo docker rm -f $(sudo docker ps -q)
sudo docker pull alitpc2525/resq:latest
sudo docker run -d -p 443:8081 -v /home/ec2-user/certbot/keystore.p12:/app/keystore.p12 -v $(pwd)/project_env_prod:/app/project_env_prod alitpc2525/resq:latest
sudo docker ps