Skip to content

Commit

Permalink
ci(github actions): disable and save state
Browse files Browse the repository at this point in the history
  • Loading branch information
anteqkois committed May 4, 2024
1 parent cbffbc3 commit fcf2938
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 5 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/deploy-changed-apps.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: deploy-changed-apps

on:
push:
branches:
- master
workflow_dispatch
# on:
# push:
# branches:
# - master

jobs:
build_and_deploy:
Expand All @@ -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:
Expand All @@ -32,3 +36,7 @@ jobs:
~/.cache/Cypress # needed for the Cypress binary
key: npm-dependencies-${{ hashFiles('package.json') }}
- run: npx [email protected] 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 }}
2 changes: 2 additions & 0 deletions apps/web/Dockerfile-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM nginx:latest
COPY ./apps/web/html/hello.html /usr/share/nginx/html/hello.html
51 changes: 51 additions & 0 deletions apps/web/build_and_deploy.sh
Original file line number Diff line number Diff line change
@@ -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 [email protected] "mkdir test2 && exit\r"
# sshpass -p "pass" ssh -o StrictHostKeyChecking=no [email protected] << EOSSH
# mkdir test2
# EOSSH
# sshpass -p "pass" ssh -v -o StrictHostKeyChecking=no [email protected] "mkdir test2 2>&1"
sshpass -p "pass" ssh -v -o StrictHostKeyChecking=no [email protected] < ./apps/web/script.sh

# expect -c "
# spawn ssh [email protected]
# 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 [email protected]
# 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
# }
# "
9 changes: 9 additions & 0 deletions apps/web/html/hello.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<p>This is an example of a simple HTML page served from the Nginx container.</p>
</body>
</html>
4 changes: 3 additions & 1 deletion apps/web/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down

0 comments on commit fcf2938

Please sign in to comment.