From cf7340b5c1de20bd86d10489cf9e1d54d0c6e564 Mon Sep 17 00:00:00 2001 From: sayyyho <323psh@naver.com> Date: Sun, 6 Oct 2024 19:56:07 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[Fix]=20-=20=EB=A7=88=EC=9D=B4=EA=B7=B8?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 67 +++++++++++------------------------- 1 file changed, 21 insertions(+), 46 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8edc51e..a525345 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,57 +1,32 @@ -name: Deploy to AWS EC2 using Docker +name: Deploy on: push: - branches: - - main - -env: - DOCKER_IMAGE_NAME: ${{ secrets.DOCKER_IMAGE_NAME }} - EC2_HOST: ${{ secrets.EC2_HOST }} - EC2_SSH_USER: ${{ secrets.EC2_SSH_USER }} - PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + branches: ["main"] jobs: - build-and-push-docker: + build: runs-on: ubuntu-latest + container: + image: pandoc/latex steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Create .env file - run: | - echo "VITE_BASE_URL=${{ secrets.VITE_BASE_URL }}" > .env - echo "VITE_GA_MEASUREMENT_ID=${{ secrets.VITE_GA_MEASUREMENT_ID }}" >> .env - - - name: Build the Docker image - run: docker build . --file Dockerfile --tag ${{ env.DOCKER_IMAGE_NAME }}:latest + - uses: actions/checkout@v3 - - name: Login to Docker Hub using Access Token - run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin + - name: creates output + run: sh ./build.sh - - name: Push the Docker image - run: docker push ${{ env.DOCKER_IMAGE_NAME }}:latest - - deploy-to-ec2: - needs: build-and-push-docker - runs-on: ubuntu-latest - - steps: - - name: Deploy to EC2 - uses: appleboy/ssh-action@master + - name: Pushes to origin repository + id: push_directory + uses: cpina/github-action-push-to-another-repository@main + env: + API_TOKEN_GITHUB: ${{ secrets.AUTO_ACTIONS }} with: - host: ${{ env.EC2_HOST }} - username: ${{ env.EC2_SSH_USER }} - key: ${{ env.PRIVATE_KEY }} - script: | - CONTAINER_ID=$(sudo docker ps -aq --filter "name=dgu-booth") - - if [ ! -z "$CONTAINER_ID" ]; then - sudo docker stop $CONTAINER_ID || true - sudo docker rm -f $CONTAINER_ID || true - fi - - sudo docker pull ${{ env.DOCKER_IMAGE_NAME }}:latest - sudo docker run --name dgu-booth-$(date +%s) -d -p 80:80 -p 3000:3000 -e TZ=Asia/Seoul ${{ env.DOCKER_IMAGE_NAME }}:latest - sudo docker image prune -f + source-directory: "output" + destination-github-username: sayyyho + destination-repository-name: 2024_fall_festival_front + user-email: "323psh@naver.com" + commit-message: "배포" + + - name: Test get variable exported by push-to-another-repository + run: echo $DESTINATION_CLONED_DIRECTORY From edd237f408a34106477f03a31a7e581d3e12934c Mon Sep 17 00:00:00 2001 From: sayyyho <323psh@naver.com> Date: Sun, 6 Oct 2024 19:57:21 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[Fix]=20-=20=EB=A7=88=EC=9D=B4=EA=B7=B8?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..c7e2521 --- /dev/null +++ b/build.sh @@ -0,0 +1,9 @@ +!/bin/sh + +cd ../ + +mkdir output + +cp -R ./2024_fall_festival_front/* ./output + +cp -R ./output ./2024_fall_festival_front \ No newline at end of file