Skip to content

Commit 7991026

Browse files
add github actions
1 parent 53f3e44 commit 7991026

File tree

6 files changed

+145
-2
lines changed

6 files changed

+145
-2
lines changed

generator/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ module.exports = (api, options) => {
1111
'lodash.clonedeep': '^4.5.0',
1212
'css-vars-ponyfill': '^2.1.2',
1313
},
14-
});
14+
})
15+
1516
if (options.useCrud) {
1617
api.extendPackage({
1718
dependencies: {
@@ -21,6 +22,10 @@ module.exports = (api, options) => {
2122
api.render('./templates/Crud', options);
2223
}
2324

25+
if (options.useGithubDeployemnts) {
26+
api.render('./templates/Deployment', options);
27+
}
28+
2429
api.render('./templates/Default', options);
2530

2631
if (options.useAuthorisation) {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# These owners will be the default owners for everything in
2+
# the repo. Unless a later match takes precedence,
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Deploy [production]
2+
3+
on:
4+
push:
5+
branches:
6+
- 'env/production'
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@master
14+
15+
- name: setup server connections
16+
env:
17+
PUBLIC_KEY: ${{ secrets.public_key }}
18+
PRIVATE_KEY: ${{ secrets.private_key }}
19+
HOST_KEY_VERIFICATION: ${{ secrets.host_key_verification }}
20+
run: |
21+
mkdir ~/.ssh
22+
echo "$PUBLIC_KEY" > ~/.ssh/id_rsa.pub
23+
echo "$PRIVATE_KEY" > ~/.ssh/id_rsa
24+
echo "$HOST_KEY_VERIFICATION" >> ~/.ssh/known_hosts
25+
ssh-keyscan -H jumphost.kingscode.nl >> ~/.ssh/known_hosts
26+
chmod 600 ~/.ssh/known_hosts
27+
chmod 600 ~/.ssh/id_rsa.pub
28+
chmod 600 ~/.ssh/id_rsa
29+
eval `ssh-agent -s`
30+
ssh-add ~/.ssh/id_rsa
31+
- name: test connection
32+
run: ssh -T jumphost@jumphost.kingscode.nl
33+
34+
- name: build .npmrc
35+
env:
36+
FONT_AWESOME_TOKEN: ${{ secrets.font_awesome_token }}
37+
run: |
38+
echo "@fortawesome:registry=https://npm.fontawesome.com/" >> .npmrc
39+
echo "//npm.fontawesome.com/:_authToken=$FONT_AWESOME_TOKEN" >> .npmrc
40+
- name: build application environment
41+
env:
42+
CLIENT_ID: ${{ secrets.client_id }}
43+
CLIENT_SECRET: ${{ secrets.client_secret }}
44+
run: |
45+
touch .env.production
46+
echo "NODE_ENV=production" >> .env.production
47+
echo "VUE_APP_ROOT_API=" >> .env.production
48+
echo "VUE_APP_CLIENT_SECRET=$CLIENT_SECRET" >> .env.production
49+
echo "VUE_APP_CLIENT_ID=$CLIENT_ID" >> .env.production
50+
echo "VUE_APP_SENTRY=" >> .env.production
51+
<%_ if (options.plugins.includes('analytics')) { _%>
52+
echo "VUE_APP_ANALYTICS=" >> .env.production
53+
<%_ } _%>
54+
<%_ if (options.plugins.includes('sentry')) { _%>
55+
echo "VUE_APP_ANALYTICS=" >> .env.production
56+
<%_ } _%>
57+
echo "VUE_APP_PUBLIC_PATH=/" >> .env.production
58+
- name: build the environment
59+
run: |
60+
npm ci
61+
npm run build
62+
- name: deployment
63+
run: |
64+
cd dist
65+
rsync -ave "ssh -o ProxyJump=jumphost@jumphost.kingscode.nl" ./ user@host:~/domains/example.com/public_html
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Deploy [test]
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@master
14+
15+
- name: setup server connections
16+
env:
17+
PUBLIC_KEY: ${{ secrets.public_key }}
18+
PRIVATE_KEY: ${{ secrets.private_key }}
19+
HOST_KEY_VERIFICATION: ${{ secrets.host_key_verification }}
20+
run: |
21+
mkdir ~/.ssh
22+
echo "$PUBLIC_KEY" > ~/.ssh/id_rsa.pub
23+
echo "$PRIVATE_KEY" > ~/.ssh/id_rsa
24+
echo "$HOST_KEY_VERIFICATION" >> ~/.ssh/known_hosts
25+
ssh-keyscan -H jumphost.kingscode.nl >> ~/.ssh/known_hosts
26+
chmod 600 ~/.ssh/known_hosts
27+
chmod 600 ~/.ssh/id_rsa.pub
28+
chmod 600 ~/.ssh/id_rsa
29+
eval `ssh-agent -s`
30+
ssh-add ~/.ssh/id_rsa
31+
- name: test connection
32+
run: ssh -T jumphost@jumphost.kingscode.nl
33+
34+
- name: build .npmrc
35+
env:
36+
FONT_AWESOME_TOKEN: ${{ secrets.font_awesome_token }}
37+
run: |
38+
echo "@fortawesome:registry=https://npm.fontawesome.com/" >> .npmrc
39+
echo "//npm.fontawesome.com/:_authToken=$FONT_AWESOME_TOKEN" >> .npmrc
40+
- name: build application environment
41+
env:
42+
CLIENT_ID: ${{ secrets.client_id }}
43+
CLIENT_SECRET: ${{ secrets.client_secret }}
44+
run: |
45+
touch .env.production
46+
echo "NODE_ENV=production" >> .env.production
47+
echo "VUE_APP_ROOT_API=" >> .env.production
48+
echo "VUE_APP_CLIENT_SECRET=$CLIENT_SECRET" >> .env.production
49+
echo "VUE_APP_CLIENT_ID=$CLIENT_ID" >> .env.production
50+
echo "VUE_APP_SENTRY=" >> .env.production
51+
echo "VUE_APP_ANALYTICS=" >> .env.production
52+
<%_ if (options.plugins.includes('analytics')) { _%>
53+
echo "VUE_APP_ANALYTICS=" >> .env.production
54+
<%_ } _%>
55+
<%_ if (options.plugins.includes('sentry')) { _%>
56+
echo "VUE_APP_ANALYTICS=" >> .env.production
57+
<%_ } _%>echo "VUE_APP_PUBLIC_PATH=/" >> .env.production
58+
- name: build the environment
59+
run: |
60+
npm ci
61+
npm run build
62+
- name: deployment
63+
run: |
64+
cd dist
65+
rsync -ave "ssh -o ProxyJump=jumphost@jumphost.kingscode.nl" ./ user@host:~/domains/example.com/public_html

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.6.0",
3+
"version": "0.7.0",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

prompts.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ module.exports = [
1515
message: 'Do you want to use authorisation (Login/register/invitation/password forgotten)',
1616
default: true,
1717
},
18+
{
19+
name: 'useGithubDeployemnts',
20+
type: 'confirm',
21+
message: 'Do you want to use github actions for deployments?',
22+
default: true,
23+
},
1824
{
1925
name: 'plugins',
2026
type: 'checkbox',

0 commit comments

Comments
 (0)