From d49ed9ddda32921e108f9e38a3248d931dc9d87a Mon Sep 17 00:00:00 2001 From: Osinachi Chukwujama Date: Thu, 15 Aug 2024 18:56:00 +0100 Subject: [PATCH] Create kimiko-golang-deployment.yml Signed-off-by: Osinachi Chukwujama --- .../workflows/kimiko-golang-deployment.yml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/kimiko-golang-deployment.yml diff --git a/.github/workflows/kimiko-golang-deployment.yml b/.github/workflows/kimiko-golang-deployment.yml new file mode 100644 index 000000000..9122f3f7d --- /dev/null +++ b/.github/workflows/kimiko-golang-deployment.yml @@ -0,0 +1,58 @@ +name: Kimiko Golang Deployment + +on: + workflow_dispatch: + workflow_run: + workflows: ["Build and Upload"] + types: + - completed + +jobs: + deploy_boilerplate_frontend: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + + environment: + name: "kimiko-golang" + url: ${{ vars.URL }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - 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: . + + - name: Create .env + uses: vicradon/create-env-action@v1.0.1 + with: + action_input_file: ".env.sample" + action_output_file: ".env" + API_URL: ${{ vars.API_URL }} + NEXTAUTH_URL: ${{ vars.URL }} + + - name: Copy Artifacts to server + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + source: ".env,boilerplate.tar.gz" + target: "~/deployments/hng_boilerplate_nextjs" + + - name: Deploy on server + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + script: | + cd ~/deployments/hng_boilerplate_nextjs + tar -xzf boilerplate.tar.gz + rm -f boilerplate.tar.gz + pm2 restart boilerplate-frontend --update-env