From 84665942a90de1751772dfc24894d83b08984570 Mon Sep 17 00:00:00 2001 From: Ravencodess <115118888+Ravencodess@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:14:04 +0100 Subject: [PATCH 1/3] Update staging-deployment.yml Signed-off-by: Ravencodess <115118888+Ravencodess@users.noreply.github.com> --- .github/workflows/staging-deployment.yml | 33 +++++++----------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/.github/workflows/staging-deployment.yml b/.github/workflows/staging-deployment.yml index 83035c7bc..0809ac44b 100644 --- a/.github/workflows/staging-deployment.yml +++ b/.github/workflows/staging-deployment.yml @@ -19,30 +19,18 @@ jobs: url: ${{ vars.URL }} steps: - - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: "20" - - name: Install pnpm - uses: pnpm/action-setup@v4 + - name: Download build artifact + uses: actions/download-artifact@v4 with: - version: 9 + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + name: boilerplate-build + path: . - name: Decode and create .env file run: | echo ${{ secrets.ENV_BASE64 }} | base64 -d > .env - - - name: Install dependencies - run: pnpm install - - - name: Build Next.js application - run: pnpm build - - - name: Archive production artifacts - run: tar -czf nextjs-staging.tar.gz .next .env - name: Copy to server uses: appleboy/scp-action@master @@ -50,11 +38,11 @@ jobs: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} password: ${{ secrets.PASSWORD }} - source: "nextjs-staging.tar.gz" + source: ".env,boilerplate.tar.gz" target: "~/hng_boilerplate_nextjs/staging" - name: Delete zip file - run: rm -f nextjs-staging.tar.gz + run: rm -f nextjs-staging.tar.gz .env - name: Deploy on server uses: appleboy/ssh-action@master @@ -68,7 +56,6 @@ jobs: git stash git reset --hard git pull - tar -xzf nextjs-staging.tar.gz - rm -f nextjs-staging.tar.gz - pnpm install + tar -xzf boilerplate.tar.gz + rm -f boilerplate.tar.gz pm2 restart boilerplate_fe_staging --update-env From 88fd9d52a0803ffd6a9632b5e7f21d253552a0df Mon Sep 17 00:00:00 2001 From: Ravencodess <115118888+Ravencodess@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:22:49 +0100 Subject: [PATCH 2/3] Update production-deployment.yml Signed-off-by: Ravencodess <115118888+Ravencodess@users.noreply.github.com> --- .github/workflows/production-deployment.yml | 33 +++++++-------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/.github/workflows/production-deployment.yml b/.github/workflows/production-deployment.yml index 270e223bc..d3d9371b6 100644 --- a/.github/workflows/production-deployment.yml +++ b/.github/workflows/production-deployment.yml @@ -19,30 +19,17 @@ jobs: url: ${{ vars.URL }} steps: - - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: "20" - - - name: Install pnpm - uses: pnpm/action-setup@v4 + - name: Download build artifact + uses: actions/download-artifact@v4 with: - version: 9 + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + name: boilerplate-build + path: . - name: Decode and create .env file run: | echo ${{ secrets.ENV_BASE64 }} | base64 -d > .env - - - name: Install dependencies - run: pnpm install - - - name: Build Next.js application - run: pnpm build - - - name: Archive production artifacts - run: tar -czf nextjs-prod.tar.gz .next .env - name: Copy to server uses: appleboy/scp-action@master @@ -50,11 +37,11 @@ jobs: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} password: ${{ secrets.PASSWORD }} - source: "nextjs-prod.tar.gz" + source: ".env,boilerplate.tar.gz" target: "~/hng_boilerplate_nextjs/prod" - name: Delete zip file - run: rm -f nextjs-prod.tar.gz + run: rm -f boilerplate.tar.gz - name: Deploy on server uses: appleboy/ssh-action@master @@ -68,7 +55,7 @@ jobs: git stash git reset --hard git pull - tar -xzf nextjs-prod.tar.gz - rm -f nextjs-prod.tar.gz + tar -xzf boilerplate.tar.gz + rm -f boilerplate.tar.gz pnpm install pm2 restart boilerplate_fe_prod --update-env From b58bdcfbce1d5ca9a54b99f749171d2ff6e5057d Mon Sep 17 00:00:00 2001 From: Ravencodess <115118888+Ravencodess@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:24:23 +0100 Subject: [PATCH 3/3] Update staging-deployment.yml Signed-off-by: Ravencodess <115118888+Ravencodess@users.noreply.github.com> --- .github/workflows/staging-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/staging-deployment.yml b/.github/workflows/staging-deployment.yml index 0809ac44b..f2e880bc1 100644 --- a/.github/workflows/staging-deployment.yml +++ b/.github/workflows/staging-deployment.yml @@ -42,7 +42,7 @@ jobs: target: "~/hng_boilerplate_nextjs/staging" - name: Delete zip file - run: rm -f nextjs-staging.tar.gz .env + run: rm -f boilerplate.tar.gz .env - name: Deploy on server uses: appleboy/ssh-action@master