-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (53 loc) · 2.11 KB
/
haha.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
name: haha
on: [workflow_dispatch]
env:
S3_BUCKET_NAME: pocket-pt
jobs:
live-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- 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@v1
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 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/my-image:$IMAGE_TAG .
docker push $ECR_REGISTRY/my-image:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/my-image:latest"
- name: Connect to EC2
uses: appleboy/ssh-action@master
with:
host: 3.38.210.49
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
docker pull 042973332120.dkr.ecr.ap-northeast-2.amazonaws.com/pocket-pt:my-image:latest
cd /home/ubuntu/Pocket-PT