This repository has been archived by the owner on Jun 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
61 lines (54 loc) · 2.79 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
name: Build and Release
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Install JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
- name: Install Postgres as dependency to run tests
run: |
docker run --name="pg" -u=postgres -e POSTGRES_PASSWORD="pg" -d --net=host cgr.dev/chainguard/postgres:latest
sleep 5
docker cp ./database/schema.sql pg:/home/postgres
docker cp ./database/trigger.sql pg:/home/postgres
docker cp ./database/data_base.sql pg:/home/postgres
docker cp ./database/data_many.sql pg:/home/postgres
docker exec pg psql -U postgres -f /home/postgres/schema.sql
docker exec pg psql -U postgres -f /home/postgres/trigger.sql
docker exec pg psql -U postgres -f /home/postgres/data_base.sql
docker exec pg psql -U postgres -f /home/postgres/data_many.sql
- name: Run tests and build with Maven if successful
working-directory: ./backend
run: mvn -B package --file pom.xml
- name: Connect to AWS and copy the application
working-directory: ./backend
shell: bash
env:
SSH_PRIVATE_KEY: ${{ secrets.AWS_PRIVATE_KEY }}
SSH_KNOWN_HOSTS: ${{ secrets.AWS_KNOWN_HOSTS }}
run: |
pwd
ls -la ../
mkdir -p ~/.ssh/
printf %s\\n "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
printf %s\\n "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/known_hosts
scp -i ~/.ssh/id_rsa target/backend-1.0.0-SNAPSHOT.jar [email protected]:/home/ubuntu/ctbs
scp -i ~/.ssh/id_rsa ../database/schema.sql [email protected]:/home/ubuntu/ctbs
scp -i ~/.ssh/id_rsa ../database/trigger.sql [email protected]:/home/ubuntu/ctbs
scp -i ~/.ssh/id_rsa ../database/data_base.sql [email protected]:/home/ubuntu/ctbs
scp -i ~/.ssh/id_rsa ../database/data_many.sql [email protected]:/home/ubuntu/ctbs
scp -i ~/.ssh/id_rsa ../.deploy/aws_push.sh [email protected]:/home/ubuntu/ctbs
scp -r -i ~/.ssh/id_rsa ../frontend [email protected]:/home/ubuntu/ctbs
ssh -i ~/.ssh/id_rsa [email protected] /home/ubuntu/ctbs/aws_push.sh