Skip to content

Commit b183f5b

Browse files
Merge pull request #15 from kingscode/new-deployments-and-robots
add/not add robots.txt prompt and new deployment
2 parents 35dd84f + 1e88f63 commit b183f5b

6 files changed

Lines changed: 84 additions & 5 deletions

File tree

generator/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ module.exports = (api, options) => {
3333
api.render('./templates/Deployment', options);
3434
}
3535

36+
if (options.addRobotsFile) {
37+
api.render('./templates/Robots', options);
38+
}
39+
3640
api.render('./templates/Default', options);
3741

3842
if (options.useAuthorisation) {

generator/templates/Deployment/_github/workflows/deploy.production.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ jobs:
3030
ssh-add ~/.ssh/id_rsa
3131
- name: test connection
3232
run: ssh -T jumphost@jumphost.kingscode.nl
33-
33+
<%_ if (options.plugins.includes('fontawesomepro')){ _%>
3434
- name: build .npmrc
3535
env:
3636
FONT_AWESOME_TOKEN: ${{ secrets.font_awesome_token }}
3737
run: |
3838
echo "@fortawesome:registry=https://npm.fontawesome.com/" >> .npmrc
3939
echo "//npm.fontawesome.com/:_authToken=$FONT_AWESOME_TOKEN" >> .npmrc
40+
<%_ } _%>
4041
- name: build application environment
4142
env:
4243
CLIENT_ID: ${{ secrets.client_id }}
@@ -57,7 +58,35 @@ jobs:
5758
run: |
5859
npm ci
5960
npm run build
61+
- name: remove /old deployment and create /new folder for deployment
62+
uses: appleboy/ssh-action@master
63+
with:
64+
host: host
65+
username: user
66+
key: ${{ secrets.private_key }}
67+
proxy_host: jumphost.kingscode.nl
68+
proxy_username: jumphost
69+
proxy_key: ${{ secrets.private_key }}
70+
script: |
71+
cd ~/domains/example.com/public_html
72+
rm -rf ./old
73+
mkdir -p ./new
74+
mkdir -p ./old
6075
- name: deployment
6176
run: |
6277
cd dist
63-
rsync -ave "ssh -o ProxyJump=jumphost@jumphost.kingscode.nl" ./ user@host:~/domains/example.com/public_html
78+
rsync -ave "ssh -o ProxyJump=jumphost@jumphost.kingscode.nl" ./ user@host:~/domains/example.com/public_html/new
79+
- name: move previous deployment to ./old and move ./new deployment to ./
80+
uses: appleboy/ssh-action@master
81+
with:
82+
host: host
83+
username: user
84+
key: ${{ secrets.private_key }}
85+
proxy_host: jumphost.kingscode.nl
86+
proxy_username: jumphost
87+
proxy_key: ${{ secrets.private_key }}
88+
script: |
89+
cd ~/domains/example.com/public_html
90+
mv `\ls -1 ./ | grep -v "\<new\>" | grep -v "\<old\>" | grep -v "\<api\>"` ./old
91+
mv ./new/* ./
92+
rm -rf ./new

generator/templates/Deployment/_github/workflows/deploy.test.yml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ jobs:
3030
ssh-add ~/.ssh/id_rsa
3131
- name: test connection
3232
run: ssh -T jumphost@jumphost.kingscode.nl
33-
33+
<%_ if (options.plugins.includes('fontawesomepro')){ _%>
3434
- name: build .npmrc
3535
env:
3636
FONT_AWESOME_TOKEN: ${{ secrets.font_awesome_token }}
3737
run: |
3838
echo "@fortawesome:registry=https://npm.fontawesome.com/" >> .npmrc
3939
echo "//npm.fontawesome.com/:_authToken=$FONT_AWESOME_TOKEN" >> .npmrc
40+
<%_ } _%>
4041
- name: build application environment
4142
env:
4243
CLIENT_ID: ${{ secrets.client_id }}
@@ -53,11 +54,48 @@ jobs:
5354
<%_ if (options.plugins.includes('sentry')) { _%>
5455
echo "VUE_APP_ANALYTICS=" >> .env.production
5556
<%_ } _%>echo "VUE_APP_PUBLIC_PATH=/" >> .env.production
57+
<%_ if (!options.addRobotsFile){ _%>
58+
- name: setup robots.txt for disallowing search engines to visit the test env
59+
run: |
60+
cd public
61+
touch robots.txt
62+
echo "" > robots.txt
63+
echo "User-agent: *" >> robots.txt
64+
echo "Disallow: /" >> robots.txt
65+
<%_ } _%>
5666
- name: build the environment
5767
run: |
5868
npm ci
5969
npm run build
70+
- name: remove /old deployment and create /new folder for deployment
71+
uses: appleboy/ssh-action@master
72+
with:
73+
host: host
74+
username: user
75+
key: ${{ secrets.private_key }}
76+
proxy_host: jumphost.kingscode.nl
77+
proxy_username: jumphost
78+
proxy_key: ${{ secrets.private_key }}
79+
script: |
80+
cd ~/domains/example.com/public_html
81+
rm -rf ./old
82+
mkdir -p ./new
83+
mkdir -p ./old
6084
- name: deployment
6185
run: |
6286
cd dist
63-
rsync -ave "ssh -o ProxyJump=jumphost@jumphost.kingscode.nl" ./ user@host:~/domains/example.com/public_html
87+
rsync -ave "ssh -o ProxyJump=jumphost@jumphost.kingscode.nl" ./ user@host:~/domains/example.com/public_html/new
88+
- name: move previous deployment to ./old and move ./new deployment to ./
89+
uses: appleboy/ssh-action@master
90+
with:
91+
host: host
92+
username: user
93+
key: ${{ secrets.private_key }}
94+
proxy_host: jumphost.kingscode.nl
95+
proxy_username: jumphost
96+
proxy_key: ${{ secrets.private_key }}
97+
script: |
98+
cd ~/domains/example.com/public_html
99+
mv `\ls -1 ./ | grep -v "\<new\>" | grep -v "\<old\>" | grep -v "\<api\>"` ./old
100+
mv ./new/* ./
101+
rm -rf ./new
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
User-agent: *
2+
Disallow: /

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-cli-plugin-kingscode-scaffold",
3-
"version": "0.7.9",
3+
"version": "0.7.10",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

prompts.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ module.exports = [
1717
message: 'Do you want to use github actions for deployments?',
1818
default: true,
1919
},
20+
{
21+
name: 'addRobotsFile',
22+
type: 'confirm',
23+
message: 'Do you want to disallow robots (SEO) to visit this applications (Y: robots.txt is placed in public folder, N: if you use github actions for deployment, in the test deployment a robots.txt is generated)',
24+
default: false,
25+
},
2026
{
2127
name: 'plugins',
2228
type: 'checkbox',

0 commit comments

Comments
 (0)