-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (73 loc) · 3.12 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
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
83
84
85
86
87
name: hoho
on: [workflow_dispatch]
jobs:
live-deploy:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Setup Java JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: cd pocketpt && chmod +x ./gradlew
shell: bash
- name: Build with Gradle
run: cd pocketpt && ./gradlew build
shell: bash
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: build docker file and setting deploy files
run: |
cd pocketpt
docker build -t studygit/pocketpt:latest .
docker push studygit/pocketpt:latest
- name: Connect to EC2
uses: appleboy/ssh-action@master
with:
host: 3.38.250.97
username: ubuntu
key: ${{ secrets.EC2_SSH_PRIVATE_KEY }}
script: |
docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" -p "${{ secrets.DOCKERHUB_TOKEN }}"
docker pull studygit/pocketpt:latest
# ECR 관련 코드 주석 처리
#- name: Login to ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v1
#- name: build docker file and setting deploy files
# env:
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# ECR_REPOSITORY: pocket-pt
# IMAGE_TAG: latest
# run: |
# cd pocketpt
# docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
# docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# - name: Connect to EC2
# uses: appleboy/ssh-action@master
# with:
# host: 3.34.49.69
# username: ubuntu
# key: ${{ secrets.EC2_SSH_PRIVATE_KEY }}
# script: |
# aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws configure set region ap-northeast-2
# aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 042973332120.dkr.ecr.ap-northeast-2.amazonaws.com
# # sudo aws ecr get-login --no-include-email --region ap-northeast-2
# # sudo $(aws ecr get-login --no-include-email --region ap-northeast-2)
# # docker login -u AWS -p $(aws ecr get-login-password) 042973332120.dkr.ecr.ap-northeast-2.amazonaws.com
# docker pull 042973332120.dkr.ecr.ap-northeast-2.amazonaws.com/pocket-pt:latest