From 60e9be8a217b5725135e293fc2d13023975ef3f0 Mon Sep 17 00:00:00 2001 From: Ravencodess <115118888+Ravencodess@users.noreply.github.com> Date: Thu, 15 Aug 2024 13:27:15 +0100 Subject: [PATCH 1/3] Update build-and-upload.yml Signed-off-by: Ravencodess <115118888+Ravencodess@users.noreply.github.com> --- .github/workflows/build-and-upload.yml | 68 +++++++++++++------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build-and-upload.yml b/.github/workflows/build-and-upload.yml index 86dc3ff7e..44e9d9e08 100644 --- a/.github/workflows/build-and-upload.yml +++ b/.github/workflows/build-and-upload.yml @@ -10,38 +10,38 @@ jobs: runs-on: ubuntu-latest if: github.event.repository.fork == false - environment: - name: "dev" - url: ${{ vars.URL }} - steps: - - uses: actions/checkout@v3 - - - name: Build Docker image - run: docker build -t hngdevops/nextjs-boilerplate:dev -f docker/development/Dockerfile . - - - name: Save and compress Docker image - run: | - docker save hngdevops/nextjs-boilerplate:dev > nextjs-dev.tar - gzip nextjs-dev.tar - - - name: Copy to server - uses: appleboy/scp-action@master - with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - password: ${{ secrets.PASSWORD }} - source: "nextjs-dev.tar.gz" - target: "/tmp/nextjs" - - - name: Load image in server - uses: appleboy/ssh-action@v1.0.3 - with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - password: ${{ secrets.PASSWORD }} - script: | - cd /tmp/nextjs - gunzip nextjs-dev.tar.gz - docker load < nextjs-dev.tar - rm -f nextjs-dev.tar + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: "20" + + - name: Cache pnpm modules + uses: actions/cache@v3 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm- + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9 + + - name: Install dependencies + run: pnpm install + + - name: Build Next.js application + run: pnpm build + + - name: Archive production artifacts + run: tar -czf aivideo-dev.tar.gz .next public + + - name: Upload coverage reports + uses: actions/upload-artifact@v3 + with: + name: boilerplate-build + path: aivideo-dev.tar.gz From 094d2f29f9d04686689a94a26135f409a56d454f Mon Sep 17 00:00:00 2001 From: Ravencodess <115118888+Ravencodess@users.noreply.github.com> Date: Thu, 15 Aug 2024 13:41:39 +0100 Subject: [PATCH 2/3] Update build-and-upload.yml Signed-off-by: Ravencodess <115118888+Ravencodess@users.noreply.github.com> --- .github/workflows/build-and-upload.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-upload.yml b/.github/workflows/build-and-upload.yml index 44e9d9e08..2daf93104 100644 --- a/.github/workflows/build-and-upload.yml +++ b/.github/workflows/build-and-upload.yml @@ -38,10 +38,10 @@ jobs: run: pnpm build - name: Archive production artifacts - run: tar -czf aivideo-dev.tar.gz .next public + run: tar -czf boilerplate.tar.gz .next public - - name: Upload coverage reports + - name: Upload production artifacts uses: actions/upload-artifact@v3 with: name: boilerplate-build - path: aivideo-dev.tar.gz + path: boilerplate.tar.gz From dfe2bdf9dce12c2e44c48443ac6d7c866cbd86c4 Mon Sep 17 00:00:00 2001 From: Ravencodess <115118888+Ravencodess@users.noreply.github.com> Date: Thu, 15 Aug 2024 13:54:48 +0100 Subject: [PATCH 3/3] Create anchor-deploy.yaml Signed-off-by: Ravencodess <115118888+Ravencodess@users.noreply.github.com> --- .github/workflows/anchor-deploy.yaml | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/anchor-deploy.yaml diff --git a/.github/workflows/anchor-deploy.yaml b/.github/workflows/anchor-deploy.yaml new file mode 100644 index 000000000..485732f78 --- /dev/null +++ b/.github/workflows/anchor-deploy.yaml @@ -0,0 +1,49 @@ +name: Anchor Deployment + +on: + workflow_run: + workflows: ["Build and Upload"] + types: + - completed + +jobs: + deploy_to_dev: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + + environment: + name: "anchor-java" + url: ${{ vars.URL }} + + steps: + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + name: boilerplate-build + path: boilerplate.tar.gz + + - name: Decode and create .env file + run: | + echo ${{ secrets.ENV }} | base64 -d > .env.java + + - name: Copy Artifacts to server + run: | + sudo apt update && sudo apt install sshpass -y + sshpass -p ${{ secrets.PASSWORD }} scp -o StrictHostKeyChecking=no boilerplate.tar.gz .env.java ${{ secrets.USERNAME }}@${{ secrets.HOST }}:/tmp/ + rm -f boilerplate.tar.gz .env + + - name: Deploy on server + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + script: | + cd boilerplate + rm -rf * + tar -xzf /tmp/boilerplate.tar.gz + mv /tmp/.env.java .env + rm -f /tmp/boilerplate.tar.gz + cp -r .next/standalone/* .