From fa948d8821337b319bb9a8e5ee52874ebb769ad8 Mon Sep 17 00:00:00 2001 From: themerous Date: Fri, 26 Jul 2024 14:38:18 +0900 Subject: [PATCH] change in github action flow --- .github/workflows/deploy.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2f86f87..9a5b9ad 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,7 +12,21 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Install pnpm + run: npm install -g pnpm + + - name: Install dependencies + run: pnpm install + + - name: Build Next.js app + run: pnpm build - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 @@ -25,8 +39,8 @@ jobs: - name: Build and push Docker image run: | - docker build -t ${{ secrets.DOCKER_USERNAME }}/react-app . - docker push ${{ secrets.DOCKER_USERNAME }}/react-app + docker build -t ${{ secrets.DOCKER_USERNAME }}/react-app:latest . + docker push ${{ secrets.DOCKER_USERNAME }}/react-app:latest - name: SSH and deploy uses: appleboy/ssh-action@master @@ -35,7 +49,7 @@ jobs: username: ${{ secrets.SERVER_USERNAME }} password: ${{ secrets.SERVER_PASSWORD }} script: | - docker pull ${{ secrets.DOCKER_USERNAME }}/react-app + docker pull ${{ secrets.DOCKER_USERNAME }}/react-app:latest docker stop react-app-container || true docker rm react-app-container || true - docker run -d -p 80:3000 --name react-app-container ${{ secrets.DOCKER_USERNAME }}/react-app + docker run -d -p 80:3000 --name react-app-container ${{ secrets.DOCKER_USERNAME }}/react-app:lastest