From ced24b34afe1be1c7a89730b059caf4066332572 Mon Sep 17 00:00:00 2001 From: Jeremy Fix Date: Thu, 13 Jun 2024 22:12:34 +0200 Subject: [PATCH 01/11] add: definition of the ssh fingerprint of the taxplorer vm --- .deploy/known_host | 1 + 1 file changed, 1 insertion(+) create mode 100644 .deploy/known_host diff --git a/.deploy/known_host b/.deploy/known_host new file mode 100644 index 0000000..65b2cae --- /dev/null +++ b/.deploy/known_host @@ -0,0 +1 @@ +129.199.194.59 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC/gPgEHsPShnmSxdcbYxc2TyfHj/bz8/sOj0u5N5zUS2VMevC59e8hfRpyNWVsJzV64u5brdSEX297lm78Zi3Ui6ZHkzjwoUYewqy9cNqNFEn6JGMPbE4TuJiA8OCMYuuv9jVu7H4vNqmKBSFclzJC/PwnAMDr57eg4sDtUTOCWcAD/tvnYRGCZ95C80oBwtSOZ7hi+odRsfYkf67XHh2UmzqabdNAtp5Itg/7ZcCKtUJIlvQN7JJqnCX8YpgZoIgouONWWC9InsfQJW8dB/5LndLm4srwucGLDh7oWG+na8TDheACovyBF3VgZMXliixJSUFEDkllZ66DA7Ecn4bufHHztS1eekq/le9nCDXdgyoeDxZY13AHsiH1tQomRQvLxjMvE6SayQtWOSDLBuOMVLuplfKQ6EJ3pSjVaJzZzdY/BjvljhaH+MDjeTRz7p5EfPGEQyl/9aNJwbNi8iTKIcXtj84NV7eH9SQsB1pLAuyfkkkbgFeceN7MQKF0eEs= From 0b41caa1aac05d3a89c8aa2f9147ec1fb0bb6327 Mon Sep 17 00:00:00 2001 From: Jeremy Fix Date: Thu, 13 Jun 2024 22:12:52 +0200 Subject: [PATCH 02/11] add: definition of the github action for remote syncing the dev site --- .github/workflows/cicd_dev.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/cicd_dev.yml diff --git a/.github/workflows/cicd_dev.yml b/.github/workflows/cicd_dev.yml new file mode 100644 index 0000000..e5bde63 --- /dev/null +++ b/.github/workflows/cicd_dev.yml @@ -0,0 +1,32 @@ +name: Copy website to the development site + +on: + push: + branches: + - dev + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + copy: + runs-on: ubuntu-latest + steps: + - name: Read the ssh private key + env: + SSH_SECRET_KEY: ${{ secrets.private_key }} + run: | + ssh-add <(echo "$SSH_SECRET_KEY" | base64 --decode) + + - name: Definition of the known host + run: | + mkdir -p ~/.ssh/ + # ssh-keyscan 129.199.194.59 > .deploy/known_host + mv .deploy/known_hosts ~/.ssh/ + chmod 644 ~/.ssh/known_hosts + + - name: Synchronization of the remote deployment + run: | + ssh d4gtaxobs@129.199.194.59 "sudo service taxplorer-dev.uwsgi stop" + ssh d4gtaxobs@129.199.194.59 "cd /opt/d4g/12_taxobservatory_dataviz_dev && git pull" + ssh d4gtaxobs@129.199.194.59 "sudo service taxplorer-dev.uwsgi start" From 01dcb1c1ae9d52115a0c4a3d61b3f4b727a3dab4 Mon Sep 17 00:00:00 2001 From: Jeremy Fix Date: Fri, 14 Jun 2024 08:55:28 +0200 Subject: [PATCH 03/11] test ssh connection --- .github/workflows/cicd_dev.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cicd_dev.yml b/.github/workflows/cicd_dev.yml index e5bde63..c28a56d 100644 --- a/.github/workflows/cicd_dev.yml +++ b/.github/workflows/cicd_dev.yml @@ -27,6 +27,7 @@ jobs: - name: Synchronization of the remote deployment run: | - ssh d4gtaxobs@129.199.194.59 "sudo service taxplorer-dev.uwsgi stop" - ssh d4gtaxobs@129.199.194.59 "cd /opt/d4g/12_taxobservatory_dataviz_dev && git pull" - ssh d4gtaxobs@129.199.194.59 "sudo service taxplorer-dev.uwsgi start" + ssh d4gtaxobs@129.199.194.59 "echo 'ok'" + #ssh d4gtaxobs@129.199.194.59 "sudo service taxplorer-dev.uwsgi stop" + #ssh d4gtaxobs@129.199.194.59 "cd /opt/d4g/12_taxobservatory_dataviz_dev && git pull" + #ssh d4gtaxobs@129.199.194.59 "sudo service taxplorer-dev.uwsgi start" From 91a90ac1631ef998bcd9789d7ab0d46aa50b1637 Mon Sep 17 00:00:00 2001 From: Jeremy Fix Date: Fri, 14 Jun 2024 09:25:24 +0200 Subject: [PATCH 04/11] test action on cicd_dev push --- .github/workflows/cicd_dev.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cicd_dev.yml b/.github/workflows/cicd_dev.yml index c28a56d..2864c35 100644 --- a/.github/workflows/cicd_dev.yml +++ b/.github/workflows/cicd_dev.yml @@ -3,7 +3,7 @@ name: Copy website to the development site on: push: branches: - - dev + - cicd_dev # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -27,7 +27,6 @@ jobs: - name: Synchronization of the remote deployment run: | - ssh d4gtaxobs@129.199.194.59 "echo 'ok'" - #ssh d4gtaxobs@129.199.194.59 "sudo service taxplorer-dev.uwsgi stop" + ssh d4gtaxobs@129.199.194.59 "sudo service taxplorer-dev.uwsgi stop" #ssh d4gtaxobs@129.199.194.59 "cd /opt/d4g/12_taxobservatory_dataviz_dev && git pull" - #ssh d4gtaxobs@129.199.194.59 "sudo service taxplorer-dev.uwsgi start" + ssh d4gtaxobs@129.199.194.59 "sudo service taxplorer-dev.uwsgi start" From a2983a631537baa89501f042a371423b8976e792 Mon Sep 17 00:00:00 2001 From: Jeremy Fix Date: Fri, 14 Jun 2024 09:27:08 +0200 Subject: [PATCH 05/11] add ssh-agent start --- .github/workflows/cicd_dev.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/cicd_dev.yml b/.github/workflows/cicd_dev.yml index 2864c35..95d65c1 100644 --- a/.github/workflows/cicd_dev.yml +++ b/.github/workflows/cicd_dev.yml @@ -12,6 +12,11 @@ jobs: copy: runs-on: ubuntu-latest steps: + - name: Install and start the ssh agent + run: | + 'which ssh-agent || ( apt-get install -qq openssh-client )' + eval $(ssh-agent -s) + - name: Read the ssh private key env: SSH_SECRET_KEY: ${{ secrets.private_key }} From d5322288f39d32c2a0a4b83c2003843172d8d3f8 Mon Sep 17 00:00:00 2001 From: Jeremy Fix Date: Fri, 14 Jun 2024 09:30:41 +0200 Subject: [PATCH 06/11] try: fix syntax for installing openssh-client --- .github/workflows/cicd_dev.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cicd_dev.yml b/.github/workflows/cicd_dev.yml index 95d65c1..f6b8721 100644 --- a/.github/workflows/cicd_dev.yml +++ b/.github/workflows/cicd_dev.yml @@ -11,10 +11,11 @@ on: jobs: copy: runs-on: ubuntu-latest + steps: - name: Install and start the ssh agent run: | - 'which ssh-agent || ( apt-get install -qq openssh-client )' + which ssh-agent || ( apt-get install -qq openssh-client ) eval $(ssh-agent -s) - name: Read the ssh private key From ed377c43377cb7e06026126bf2d5a34a02bf5d56 Mon Sep 17 00:00:00 2001 From: Jeremy Fix Date: Fri, 14 Jun 2024 09:35:33 +0200 Subject: [PATCH 07/11] try: should I run the ssh-agent in the same step as adding the ssh key ? --- .github/workflows/cicd_dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cicd_dev.yml b/.github/workflows/cicd_dev.yml index f6b8721..b54e7fb 100644 --- a/.github/workflows/cicd_dev.yml +++ b/.github/workflows/cicd_dev.yml @@ -22,6 +22,7 @@ jobs: env: SSH_SECRET_KEY: ${{ secrets.private_key }} run: | + eval $(ssh-agent -s) ssh-add <(echo "$SSH_SECRET_KEY" | base64 --decode) - name: Definition of the known host From 6c4b64a00426f3c53404514760e17ba1bec01e7c Mon Sep 17 00:00:00 2001 From: Jeremy Fix Date: Fri, 14 Jun 2024 09:48:29 +0200 Subject: [PATCH 08/11] fix: name of the secret --- .github/workflows/cicd_dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd_dev.yml b/.github/workflows/cicd_dev.yml index b54e7fb..860e15d 100644 --- a/.github/workflows/cicd_dev.yml +++ b/.github/workflows/cicd_dev.yml @@ -20,7 +20,7 @@ jobs: - name: Read the ssh private key env: - SSH_SECRET_KEY: ${{ secrets.private_key }} + SSH_SECRET_KEY: ${{ secrets.SSH_SECRET_KEY }} run: | eval $(ssh-agent -s) ssh-add <(echo "$SSH_SECRET_KEY" | base64 --decode) From 88bd281106b545f94d59275c68949eae475bcd80 Mon Sep 17 00:00:00 2001 From: Jeremy Fix Date: Fri, 14 Jun 2024 09:51:17 +0200 Subject: [PATCH 09/11] fix: know host filename --- .deploy/{known_host => known_hosts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .deploy/{known_host => known_hosts} (100%) diff --git a/.deploy/known_host b/.deploy/known_hosts similarity index 100% rename from .deploy/known_host rename to .deploy/known_hosts From 115d92f98567184d36299a89aaaa376ab60898c9 Mon Sep 17 00:00:00 2001 From: Jeremy Fix Date: Fri, 14 Jun 2024 09:57:19 +0200 Subject: [PATCH 10/11] fix: checkout the code --- .github/workflows/cicd_dev.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cicd_dev.yml b/.github/workflows/cicd_dev.yml index 860e15d..262a52c 100644 --- a/.github/workflows/cicd_dev.yml +++ b/.github/workflows/cicd_dev.yml @@ -13,6 +13,9 @@ jobs: runs-on: ubuntu-latest steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Install and start the ssh agent run: | which ssh-agent || ( apt-get install -qq openssh-client ) From 3e71b1a49b950260164943dfcdcfb06f5cbe18a7 Mon Sep 17 00:00:00 2001 From: Jeremy Fix Date: Fri, 14 Jun 2024 10:52:20 +0200 Subject: [PATCH 11/11] probe the IP of the github action machine --- .github/workflows/cicd_dev.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/cicd_dev.yml b/.github/workflows/cicd_dev.yml index 262a52c..a099344 100644 --- a/.github/workflows/cicd_dev.yml +++ b/.github/workflows/cicd_dev.yml @@ -35,6 +35,10 @@ jobs: mv .deploy/known_hosts ~/.ssh/ chmod 644 ~/.ssh/known_hosts + - name: Check the IP of the machine + run: | + ip addr + - name: Synchronization of the remote deployment run: | ssh d4gtaxobs@129.199.194.59 "sudo service taxplorer-dev.uwsgi stop"