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