From 5bc976fcda7a6d2cf5e8aa08fe4a62808f4e5f33 Mon Sep 17 00:00:00 2001 From: Koen Hoeijmakers Date: Mon, 6 Apr 2020 10:29:28 +0200 Subject: [PATCH 1/2] chore: fix deploy script defaults --- .../_github/workflows/deploy.production.yml | 41 +++++----- .../_github/workflows/deploy.test.yml | 74 ++++++++++--------- 2 files changed, 61 insertions(+), 54 deletions(-) diff --git a/generator/templates/Deployment/_github/workflows/deploy.production.yml b/generator/templates/Deployment/_github/workflows/deploy.production.yml index bf8efe6..14a1702 100644 --- a/generator/templates/Deployment/_github/workflows/deploy.production.yml +++ b/generator/templates/Deployment/_github/workflows/deploy.production.yml @@ -28,8 +28,10 @@ jobs: chmod 600 ~/.ssh/id_rsa eval `ssh-agent -s` ssh-add ~/.ssh/id_rsa + - name: test connection run: ssh -T jumphost@jumphost.kingscode.nl + <%_ if (options.plugins.includes('fontawesomepro')){ _%> - name: build .npmrc env: @@ -38,26 +40,25 @@ jobs: echo "@fortawesome:registry=https://npm.fontawesome.com/" >> .npmrc echo "//npm.fontawesome.com/:_authToken=$FONT_AWESOME_TOKEN" >> .npmrc <%_ } _%> + - name: build application environment - env: - CLIENT_ID: ${{ secrets.client_id }} - CLIENT_SECRET: ${{ secrets.client_secret }} run: | touch .env.production echo "NODE_ENV=production" >> .env.production echo "VUE_APP_ROOT_API=" >> .env.production - echo "VUE_APP_SENTRY=" >> .env.production <%_ if (options.plugins.includes('analytics')) { _%> echo "VUE_APP_ANALYTICS=" >> .env.production <%_ } _%> <%_ if (options.plugins.includes('sentry')) { _%> - echo "VUE_APP_ANALYTICS=" >> .env.production + echo "VUE_APP_SENTRY=" >> .env.production <%_ } _%> echo "VUE_APP_PUBLIC_PATH=/" >> .env.production - - name: build the environment + + - name: build run: | npm ci npm run build + - name: remove /old deployment and create /new folder for deployment uses: appleboy/ssh-action@master with: @@ -72,21 +73,23 @@ jobs: rm -rf ./old mkdir -p ./new mkdir -p ./old + - name: deployment run: | cd dist rsync -ave "ssh -o ProxyJump=jumphost@jumphost.kingscode.nl" ./ user@host:~/domains/example.com/public_html/new + - name: move previous deployment to ./old and move ./new deployment to ./ - uses: appleboy/ssh-action@master - with: - host: host - username: user - key: ${{ secrets.private_key }} - proxy_host: jumphost.kingscode.nl - proxy_username: jumphost - proxy_key: ${{ secrets.private_key }} - script: | - cd ~/domains/example.com/public_html - mv `\ls -1 ./ | grep -v "\" | grep -v "\" | grep -v "\"` ./old - mv ./new/* ./ - rm -rf ./new + uses: appleboy/ssh-action@master + with: + host: host + username: user + key: ${{ secrets.private_key }} + proxy_host: jumphost.kingscode.nl + proxy_username: jumphost + proxy_key: ${{ secrets.private_key }} + script: | + cd ~/domains/example.com/public_html + mv `\ls -1 ./ | grep -v "\" | grep -v "\" | grep -v "\"` ./old + mv ./new/* ./ + rm -rf ./new diff --git a/generator/templates/Deployment/_github/workflows/deploy.test.yml b/generator/templates/Deployment/_github/workflows/deploy.test.yml index 8e9db28..5357770 100644 --- a/generator/templates/Deployment/_github/workflows/deploy.test.yml +++ b/generator/templates/Deployment/_github/workflows/deploy.test.yml @@ -28,8 +28,10 @@ jobs: chmod 600 ~/.ssh/id_rsa eval `ssh-agent -s` ssh-add ~/.ssh/id_rsa - - name: test connection + + - name: test jumphost connection run: ssh -T jumphost@jumphost.kingscode.nl + <%_ if (options.plugins.includes('fontawesomepro')){ _%> - name: build .npmrc env: @@ -38,22 +40,20 @@ jobs: echo "@fortawesome:registry=https://npm.fontawesome.com/" >> .npmrc echo "//npm.fontawesome.com/:_authToken=$FONT_AWESOME_TOKEN" >> .npmrc <%_ } _%> + - name: build application environment - env: - CLIENT_ID: ${{ secrets.client_id }} - CLIENT_SECRET: ${{ secrets.client_secret }} run: | touch .env.production echo "NODE_ENV=production" >> .env.production echo "VUE_APP_ROOT_API=" >> .env.production - echo "VUE_APP_SENTRY=" >> .env.production - echo "VUE_APP_ANALYTICS=" >> .env.production <%_ if (options.plugins.includes('analytics')) { _%> echo "VUE_APP_ANALYTICS=" >> .env.production <%_ } _%> <%_ if (options.plugins.includes('sentry')) { _%> - echo "VUE_APP_ANALYTICS=" >> .env.production - <%_ } _%>echo "VUE_APP_PUBLIC_PATH=/" >> .env.production + echo "VUE_APP_SENTRY=" >> .env.production + <%_ } _%> + echo "VUE_APP_PUBLIC_PATH=/" >> .env.production + <%_ if (!options.addRobotsFile){ _%> - name: setup robots.txt for disallowing search engines to visit the test env run: | @@ -63,39 +63,43 @@ jobs: echo "User-agent: *" >> robots.txt echo "Disallow: /" >> robots.txt <%_ } _%> - - name: build the environment + + - name: build run: | npm ci npm run build + - name: remove /old deployment and create /new folder for deployment - uses: appleboy/ssh-action@master - with: - host: host - username: user - key: ${{ secrets.private_key }} - proxy_host: jumphost.kingscode.nl - proxy_username: jumphost - proxy_key: ${{ secrets.private_key }} - script: | - cd ~/domains/example.com/public_html - rm -rf ./old - mkdir -p ./new - mkdir -p ./old + uses: appleboy/ssh-action@master + with: + host: host + username: user + key: ${{ secrets.private_key }} + proxy_host: jumphost.kingscode.nl + proxy_username: jumphost + proxy_key: ${{ secrets.private_key }} + script: | + cd ~/domains/example.com/public_html + rm -rf ./old + mkdir -p ./new + mkdir -p ./old + - name: deployment run: | cd dist rsync -ave "ssh -o ProxyJump=jumphost@jumphost.kingscode.nl" ./ user@host:~/domains/example.com/public_html/new + - name: move previous deployment to ./old and move ./new deployment to ./ - uses: appleboy/ssh-action@master - with: - host: host - username: user - key: ${{ secrets.private_key }} - proxy_host: jumphost.kingscode.nl - proxy_username: jumphost - proxy_key: ${{ secrets.private_key }} - script: | - cd ~/domains/example.com/public_html - mv `\ls -1 ./ | grep -v "\" | grep -v "\" | grep -v "\"` ./old - mv ./new/* ./ - rm -rf ./new + uses: appleboy/ssh-action@master + with: + host: host + username: user + key: ${{ secrets.private_key }} + proxy_host: jumphost.kingscode.nl + proxy_username: jumphost + proxy_key: ${{ secrets.private_key }} + script: | + cd ~/domains/example.com/public_html + mv `\ls -1 ./ | grep -v "\" | grep -v "\" | grep -v "\"` ./old + mv ./new/* ./ + rm -rf ./new From f3873f05702215c3c936cf45dcc93c34f3f384e3 Mon Sep 17 00:00:00 2001 From: Koen Hoeijmakers Date: Tue, 7 Apr 2020 08:57:52 +0200 Subject: [PATCH 2/2] feature: add shopt -s dotglob --- .../Deployment/_github/workflows/deploy.production.yml | 2 ++ .../Deployment/_github/workflows/deploy.test.yml | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/generator/templates/Deployment/_github/workflows/deploy.production.yml b/generator/templates/Deployment/_github/workflows/deploy.production.yml index 14a1702..5ffe41d 100644 --- a/generator/templates/Deployment/_github/workflows/deploy.production.yml +++ b/generator/templates/Deployment/_github/workflows/deploy.production.yml @@ -69,6 +69,7 @@ jobs: proxy_username: jumphost proxy_key: ${{ secrets.private_key }} script: | + shopt -s dotglob cd ~/domains/example.com/public_html rm -rf ./old mkdir -p ./new @@ -89,6 +90,7 @@ jobs: proxy_username: jumphost proxy_key: ${{ secrets.private_key }} script: | + shopt -s dotglob cd ~/domains/example.com/public_html mv `\ls -1 ./ | grep -v "\" | grep -v "\" | grep -v "\"` ./old mv ./new/* ./ diff --git a/generator/templates/Deployment/_github/workflows/deploy.test.yml b/generator/templates/Deployment/_github/workflows/deploy.test.yml index 5357770..aee60cc 100644 --- a/generator/templates/Deployment/_github/workflows/deploy.test.yml +++ b/generator/templates/Deployment/_github/workflows/deploy.test.yml @@ -32,14 +32,14 @@ jobs: - name: test jumphost connection run: ssh -T jumphost@jumphost.kingscode.nl - <%_ if (options.plugins.includes('fontawesomepro')){ _%> +<%_ if (options.plugins.includes('fontawesomepro')){ _%> - name: build .npmrc env: FONT_AWESOME_TOKEN: ${{ secrets.font_awesome_token }} run: | echo "@fortawesome:registry=https://npm.fontawesome.com/" >> .npmrc echo "//npm.fontawesome.com/:_authToken=$FONT_AWESOME_TOKEN" >> .npmrc - <%_ } _%> +<%_ } _%> - name: build application environment run: | @@ -54,7 +54,7 @@ jobs: <%_ } _%> echo "VUE_APP_PUBLIC_PATH=/" >> .env.production - <%_ if (!options.addRobotsFile){ _%> +<%_ if (!options.addRobotsFile){ _%> - name: setup robots.txt for disallowing search engines to visit the test env run: | cd public @@ -62,7 +62,7 @@ jobs: echo "" > robots.txt echo "User-agent: *" >> robots.txt echo "Disallow: /" >> robots.txt - <%_ } _%> +<%_ } _%> - name: build run: | @@ -79,6 +79,7 @@ jobs: proxy_username: jumphost proxy_key: ${{ secrets.private_key }} script: | + shopt -s dotglob cd ~/domains/example.com/public_html rm -rf ./old mkdir -p ./new @@ -99,6 +100,7 @@ jobs: proxy_username: jumphost proxy_key: ${{ secrets.private_key }} script: | + shopt -s dotglob cd ~/domains/example.com/public_html mv `\ls -1 ./ | grep -v "\" | grep -v "\" | grep -v "\"` ./old mv ./new/* ./