prod-pocket-pt #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: prod-pocket-pt | |
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.PROD_DOCKERHUB_USERNAME }} | |
password: ${{ secrets.PROD_DOCKERHUB_TOKEN }} | |
- name: build docker file and setting deploy files | |
run: | | |
cd pocketpt | |
docker build -t ${{ secrets.PROD_DOCKERHUB_USERNAME }}/prod-pocket-pt:latest . | |
docker push ${{ secrets.PROD_DOCKERHUB_USERNAME }}/prod-pocket-pt:latest | |
# - name: Connect to EC2 | |
# uses: appleboy/ssh-action@master | |
# with: | |
# host: 43.201.94.99 | |
# username: ubuntu | |
# key: ${{ secrets.EC2_SSH_PRIVATE_KEY }} | |
# script: | | |
# ssh [email protected] | |
# docker login -u "${{ secrets.PROD_DOCKERHUB_USERNAME }}" -p "${{ secrets.PROD_DOCKERHUB_TOKEN }}" | |
# docker pull ${{ secrets.PROD_DOCKERHUB_USERNAME }}/prod-pocket-pt:latest | |
- name: Connect to EC2 using SSH Key | |
uses: appleboy/ssh-action@master | |
with: | |
host: 43.201.94.99 | |
username: ubuntu | |
key: ${{ secrets.EC2_SSH_PRIVATE_KEY }} | |
script: | | |
echo "${{ secrets.EC2_SSH_PRIVATE_KEY }}" > private_key.pem | |
chmod 600 private_key.pem | |
ssh -i private_key.pem [email protected] <<EOF | |
echo "Connected to private EC2 instance" | |
docker login -u "${{ secrets.PROD_DOCKERHUB_USERNAME }}" -p "${{ secrets.PROD_DOCKERHUB_TOKEN }}" | |
docker pull ${{ secrets.PROD_DOCKERHUB_USERNAME }}/prod-pocket-pt:latest | |
EOF | |
# 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 |