From 1c754678f07b17f17f12ab78aeab007be8bfa8a1 Mon Sep 17 00:00:00 2001 From: xiaomlove <353856593@qq.com> Date: Fri, 24 Mar 2023 21:38:23 +0800 Subject: [PATCH 1/4] create demo.yml --- .github/workflows/demo.yml | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/demo.yml diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml new file mode 100644 index 00000000..edd2acd2 --- /dev/null +++ b/.github/workflows/demo.yml @@ -0,0 +1,40 @@ +name: deploy to demo site +on: + push: + branches: [ "php8" ] + +# Environment variables available to all jobs and steps in this workflow +env: + SSH_KEY: ${{secrets.DEMO_SSH_KEY}} + SSH_USER: ${{secrets.DEMO_SSH_USER}} + SSH_HOST: ${{secrets.DEMO_SSH_HOST}} + DEMO_WEB_ROOT: ${{secrets.DEMO_WEB_ROOT}} +permissions: + contents: read +jobs: + login-to-demo-and-up: + name: Login to demo and Deploy + runs-on: ubuntu-latest + environment: production + steps: + # Prepare + - name: Prepare user key + run: | + mkdir -p ~/.ssh/ + echo "$SSH_KEY" > ~/.ssh/demo.key + chmod 600 ~/.ssh/demo.key + cat >> ~/.ssh/config < Date: Sat, 25 Mar 2023 17:03:44 +0800 Subject: [PATCH 2/4] action echo some variables --- .github/workflows/demo.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index edd2acd2..494d692d 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -30,6 +30,7 @@ jobs: IdentityFile ~/.ssh/demo.key StrictHostKeyChecking no END + echo "user: $SSH_USER, host: $SSH_HOST, path: $DEMO_WEB_ROOT" # Deploy - name: Fetch code and update run: | From cefd2c0cdce599ad67688a0139dd48ce25bb4580 Mon Sep 17 00:00:00 2001 From: xiaomlove <353856593@qq.com> Date: Sat, 25 Mar 2023 17:09:49 +0800 Subject: [PATCH 3/4] Update demo.yml --- .github/workflows/demo.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index 494d692d..0ff52b6b 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -34,8 +34,8 @@ jobs: # Deploy - name: Fetch code and update run: | - ssh demo 'cd $DEMO_WEB_ROOT && php artisan nexus:update --tag=dev' - ssh demo 'cd $DEMO_WEB_ROOT && php artisan nexus:update' + ssh demo "cd $DEMO_WEB_ROOT && php artisan nexus:update --tag=dev" + ssh demo "cd $DEMO_WEB_ROOT && php artisan nexus:update" From 7f6a46be2dd164cb76114c6769125731d4dd9b7d Mon Sep 17 00:00:00 2001 From: xiaomlove <353856593@qq.com> Date: Sat, 25 Mar 2023 17:18:01 +0800 Subject: [PATCH 4/4] Update demo.yml --- .github/workflows/demo.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index 0ff52b6b..df53b543 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -30,12 +30,11 @@ jobs: IdentityFile ~/.ssh/demo.key StrictHostKeyChecking no END - echo "user: $SSH_USER, host: $SSH_HOST, path: $DEMO_WEB_ROOT" # Deploy - - name: Fetch code and update - run: | - ssh demo "cd $DEMO_WEB_ROOT && php artisan nexus:update --tag=dev" - ssh demo "cd $DEMO_WEB_ROOT && php artisan nexus:update" + - name: Fetch code + run: ssh demo "cd $DEMO_WEB_ROOT && php artisan nexus:update --tag=dev" + - name: Update + run: ssh demo "cd $DEMO_WEB_ROOT && php artisan nexus:update"