diff --git a/.github/workflows/deploy-changed-apps.yml b/.github/workflows/deploy-changed-apps.yml index c584e130..2075e6fd 100644 --- a/.github/workflows/deploy-changed-apps.yml +++ b/.github/workflows/deploy-changed-apps.yml @@ -1,9 +1,11 @@ name: deploy-changed-apps on: - push: - branches: - - master + workflow_dispatch +# on: +# push: +# branches: +# - master jobs: build_and_deploy: @@ -23,7 +25,9 @@ jobs: node_modules ~/.cache/Cypress # needed for the Cypress binary key: npm-dependencies-${{ hashFiles('package.json') }} - - run: pnpm install + - name: Install dependencies + run: pnpm install + if: steps.cache.outputs.cache-hit != 'true' - name: Cache npm dependencies uses: actions/cache/save@v3 with: @@ -32,3 +36,7 @@ jobs: ~/.cache/Cypress # needed for the Cypress binary key: npm-dependencies-${{ hashFiles('package.json') }} - run: npx nx@18.3.4 affected -t docker-compose --base=origin/master~1 --head=origin/master + - name: Install doctl + uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} diff --git a/apps/web/Dockerfile-test b/apps/web/Dockerfile-test new file mode 100644 index 00000000..02f4d72b --- /dev/null +++ b/apps/web/Dockerfile-test @@ -0,0 +1,2 @@ +FROM nginx:latest +COPY ./apps/web/html/hello.html /usr/share/nginx/html/hello.html diff --git a/apps/web/build_and_deploy.sh b/apps/web/build_and_deploy.sh new file mode 100644 index 00000000..c8bd4980 --- /dev/null +++ b/apps/web/build_and_deploy.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +set -e + +# # Build images +# docker build -t linkerry/test -f ./apps/web/Dockerfile-test . + +# # Push docker image to container registry +# docker login -u "$CONTAINER_REGISTRY_USERNAME" -p "$CONTAINER_REGISTRY_PASSWORD" "$CONTAINER_REGISTRY_ADDRESS" + +# docker tag linkerry/test registry.digitalocean.com/linkerry/web:"$ENV" +# docker push registry.digitalocean.com/linkerry/web:"$ENV" + +# prepare env file + +# sshpass -p "$SSH_PASSPHRASE" ssh root@64.226.97.74 "mkdir test2 && exit\r" +# sshpass -p "pass" ssh -o StrictHostKeyChecking=no root@64.226.97.74 << EOSSH +# mkdir test2 +# EOSSH +# sshpass -p "pass" ssh -v -o StrictHostKeyChecking=no root@64.226.97.74 "mkdir test2 2>&1" +sshpass -p "pass" ssh -v -o StrictHostKeyChecking=no root@64.226.97.74 < ./apps/web/script.sh + +# expect -c " +# spawn ssh root@64.226.97.74 +# expect \"Enter passphrase for key '/Users/anteqkois/.ssh/id_rsa':\" +# send \"$SSH_PASSPHRASE\r\" +# interact +# " + +# # Use expect to interact with the SSH command +# expect -c " +# spawn ssh root@64.226.97.74 +# expect { +# \"Enter passphrase for key '$SSH_KEY_PATH':\" { +# send \"$SSH_PASSPHRASE\r\" +# exp_continue +# } +# \"assword:\" { +# send \"$SSH_PASSPHRASE\r\" +# exp_continue +# } +# \"yes/no\" { +# send \"yes\r\" +# exp_continue +# } +# eof +# # Run commands on the remote server +# send \"mkdir test2 && exit\r\" +# expect eof +# } +# " diff --git a/apps/web/html/hello.html b/apps/web/html/hello.html new file mode 100644 index 00000000..a71b99af --- /dev/null +++ b/apps/web/html/hello.html @@ -0,0 +1,9 @@ + + + + Hello World! + + +

This is an example of a simple HTML page served from the Nginx container.

+ + diff --git a/apps/web/project.json b/apps/web/project.json index 548bbf8e..b8e0be64 100644 --- a/apps/web/project.json +++ b/apps/web/project.json @@ -7,7 +7,9 @@ "// targets": "to see all targets run: nx show project web --web", "targets": { "docker-compose": { - "command": " echo \"web\" was changed" + "command": "bash ./apps/web/build_and_deploy.sh" + // "command": "docker build -t linkerry/test -f ./apps/web/Dockerfile-test ." + // "command": " echo \"web\" was changed" // "command": "docker compose -f ./apps/web/docker-compose.local.yml up -d" } }