hoho #114
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: 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 |