Skip to content

Commit b150f92

Browse files
authored
Merge pull request #46 from ioet/test
CD
2 parents 9380312 + 191837a commit b150f92

File tree

10 files changed

+146
-39
lines changed

10 files changed

+146
-39
lines changed

.github/workflows/CD-azure-functions.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/CD.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CD process to deploy to AzureFuncions
2+
3+
on:
4+
# Trigger the workflow on pull request but only for the master branch
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: [10.x]
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@master
18+
19+
- uses: azure/login@v1
20+
with:
21+
creds: ${{ secrets.AZURE_CREDENTIALS }}
22+
23+
- name: Azure CLI script
24+
uses: azure/CLI@v1
25+
with:
26+
azcliversion: 2.0.72
27+
inlineScript: |
28+
az account show
29+
az storage -h
30+
31+
- name: Use Node.js ${{ matrix.node-version }}
32+
uses: actions/setup-node@v1
33+
with:
34+
node-version: ${{ matrix.node-version }}
35+
36+
- name: Install SOPS
37+
run: |
38+
sudo apt-get install wget
39+
wget https://github.com/mozilla/sops/releases/download/v3.7.0/sops_3.7.0_amd64.deb
40+
sudo dpkg -i sops_3.7.0_amd64.deb
41+
42+
- name: Decrypt Secrets
43+
run: make sops-decrypt-nodejs
44+
45+
- name: Install NodeJs dependencies
46+
run: make install-dependencies-nodejs
47+
48+
- name: Install Serverless Framework
49+
run: sudo npm install -g serverless
50+
51+
- name: Install Serverless Plugins
52+
run: make deploy-nodejs
53+

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ appsettings.json
2424
local.settings.json
2525

2626
node_modules
27-
28-
AutomaticClockOuts/node_modules
2927
.idea/
3028
.vscode/
31-
serverless.yml
29+
.serverless
30+
keys.yml.bk

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
help: Makefile
2+
@sed -n 's/^## //p' $<
3+
4+
## npm-install-functions -> Added dependencies in case that the functions need, add manually the command and Makefile
5+
install-dependencies-nodejs:
6+
cd nodejs-functions ; pwd ; $(MAKE) install-dependencies-nodejs
7+
8+
install-serverless-plugins:
9+
cd nodejs-functions ; pwd ; make install-serverless-plugins
10+
11+
deploy-nodejs:
12+
cd nodejs-functions ; pwd ; make deploy
13+
14+
sops-decrypt-nodejs:
15+
cd nodejs-functions ; pwd ; make sops-decrypt
-8.13 MB
Binary file not shown.

nodejs-functions/.sops.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
creation_rules:
2+
- path_regex: keys.yml.*
3+
azure_keyvault: https://time-tracker-secrets.vault.azure.net/keys/tt-functions-sops/021de58b06a1497881bbacf4c82b83d7

nodejs-functions/Makefile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1+
SECRETS=keys.yml
12
help: Makefile
23
@sed -n 's/^## //p' $<
34

4-
## run -> run serverless function
5-
run:
6-
sls offline
5+
## npm-install-functions -> Added dependencies in case that the functions need, add manually the command and Makefile
6+
install-dependencies-nodejs:
7+
cd src/handlers/automatic-clock-outs ; pwd ; $(MAKE) install
8+
9+
deploy:
10+
sls deploy
11+
12+
sops-encrypt:
13+
sops -e -i ${SECRETS}
14+
15+
sops-decrypt:
16+
sops -d -i ${SECRETS}
17+
18+
install-serverless-plugins:
19+
serverless plugin install --name serverless-azure-functions

nodejs-functions/keys.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
ENDPOINT: ENC[AES256_GCM,data:Hkm+9x/NJyWVRiaZhAnkwZRI8qMq/fNxikATLX0ncb+CuQNDRm+lgErGzrjAKLKo,iv:Jfzi5siEMjDBC5M4WJNqWB0RESWTc9xlII55YdACa84=,tag:qTuYwzTNMxojvyIYyqJFsg==,type:str]
2+
KEY: ENC[AES256_GCM,data:KEQ9/toDaCxeBa8ZWCiaqUEBv4z4kIIXvvupXbnGvwqQ7nzSQo00kzEuBloJNHudc7TuYiSqyYESUBNQQ/fRTIb/sZCwxGXnH386tIMZSzpFBUQYB0QbQQ==,iv:sDOFPxzstnhbIFilvxINYMjZxS+UZmShl/RNoyCSaP8=,tag:bGk2MCZ+pM8nOaW4tUXJHg==,type:str]
3+
CLIENT_ID: ENC[AES256_GCM,data:Uq5JLAEziobuUiTpUAecHexraLABQXKAa0s4tU8dA+J26XD2,iv:JojFPnaUkTWp9JwfgJRGE+tHOEgtBvHPFqT/yJ9BIuc=,tag:TyK0UQ4pue+U2aFnyDmIFA==,type:str]
4+
AUTHORITY: ENC[AES256_GCM,data:7gpZv5zFzB+08eoI6I9abJcU6J2SHcFv9YnGSfDEBf88z3rl+9iHGYRStzsauyxZKqekidexsAm1VaYMCrZ9Tu+dHK9Gug==,iv:o+B6KenwnytllxfET0JhBRnoAkpDTgvi4i4AYCfY3Wg=,tag:8pwqBx9ptOUxi4T3L1OW2A==,type:str]
5+
CLIENT_SECRET: ENC[AES256_GCM,data:wkxsgXMpjQeN0cx8X7PgZNPl9DJ9fOw+pKMllD2Kidk=,iv:xAzVNQfFwVmbwNWr8pFfESu/DV/WaQmOazmCLr0QbK8=,tag:cq+vjN5cf/0cZlAbYlZ3VQ==,type:str]
6+
SLACK_TOKEN_NOTIFY: ENC[AES256_GCM,data:AXa10lmQjrTJtvUQcxMQfEJHCrH2LK5Pk1z3yZotJob4/L3eJRrPkSizPLr2O4q7iauuycpm,iv:hSTEwOGEKoiVCXCs9zCSWcoMEKDNNzt3c7+Q/gaSrdU=,tag:0jOv6Dx4UAKh99TejpkBFg==,type:str]
7+
TEST: ENC[AES256_GCM,data:skwJkLTLeS9fqOs10RQ=,iv:S4dbSww3+R9xOR7kcQKAcUDU9ZS1+JEpiCB6zjYCqJI=,tag:Gw520XvjZwcJ/1BOU5B2cQ==,type:str]
8+
sops:
9+
kms: []
10+
gcp_kms: []
11+
azure_kv:
12+
- vault_url: https://time-tracker-secrets.vault.azure.net
13+
name: tt-functions-sops
14+
version: 021de58b06a1497881bbacf4c82b83d7
15+
created_at: "2021-03-26T04:44:58Z"
16+
enc: BavLdI0vYqkLklbXpGRQ1gUFlaTt4dS0EjgCv0KbrkyLHhgdjYk79S0o4wDlDN_GIVc4zNelMPWXs22c9F99IxIpS1L84VUp50LmEvbXx8cOmYKpWfIK6JzgXE9VbtReOFwWP1OaqnS37Z714xR2Uv1z5AvMZZpC6s4303Zo6IDXz1bJeigK544YVceI-79YV7z0QDyXux-CoecwQpxpKVIA5jpBXKqLQU8r-WVwSyszCliedaTMJNBoRJSn3AEr2i3qW6DRkSltgIv9mSSnx8IvLjCAgnuG0cPwne7YITFoB2i_nLVMSeXuYkUVVQvvuYUycs1_NWobs828aD-gvQ
17+
hc_vault: []
18+
age: []
19+
lastmodified: "2021-03-26T04:45:00Z"
20+
mac: ENC[AES256_GCM,data:ng3bl2jD7EznuDKCfOIs06g0tYlFn69rCPJvjP7ndfiVD9H4prg63z/7fUPLD3eILD+tNh44aAspKkDQAb3NuIlLJ69+9L+4jE08Iq8ZaAlMjqkshtUlFyQ+gS8vZtrdkjQw9538YGQ0Xnf0yDfkVw63KATshrfOidWBuw1vT7U=,iv:XDlTF0E1zaQ6qxLw4LFP4aTfNmFYMFAoM1Xt7G8OMR8=,tag:0Nk524idBlSb2J7bovBIaQ==,type:str]
21+
pgp: []
22+
unencrypted_suffix: _unencrypted
23+
version: 3.7.0

nodejs-functions/package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
"serverless"
1212
],
1313
"dependencies": {
14-
"@azure/cosmos": "3.5.2",
15-
"@azure/msal-node": "^1.0.0-alpha.5",
16-
"axios": "^0.20.0",
17-
"dotenv": "^8.2.0",
18-
"moment": "^2.27.0",
19-
"msal": "^1.4.0"
2014
},
2115
"devDependencies": {
2216
"serverless-azure-functions": "^2.1.0"

nodejs-functions/serverless.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
service: nodejs-functions
2+
frameworkVersion: "2"
3+
4+
provider:
5+
name: azure
6+
region: West US 2
7+
runtime: nodejs12
8+
# linux is the only operating system available for python
9+
os: linux
10+
# prefix of generated resource name
11+
prefix: time-tracker
12+
environment:
13+
ENDPOINT: ${file(keys.yml):ENDPOINT}
14+
KEY: ${file(keys.yml):KEY}
15+
CLIENT_ID: ${file(keys.yml):CLIENT_ID}
16+
AUTHORITY: ${file(keys.yml):AUTHORITY}
17+
CLIENT_SECRET: ${file(keys.yml):CLIENT_SECRET}
18+
SLACK_TOKEN_NOTIFY: ${file(keys.yml):SLACK_TOKEN_NOTIFY}
19+
TEST: ${file(keys.yml):TEST}
20+
21+
custom:
22+
globalSchedule: cron(0 0 * * *)
23+
plugins:
24+
- serverless-azure-functions
25+
package:
26+
exclude:
27+
- local.settings.json
28+
- .vscode/**
29+
functions:
30+
automatic-clock-outs:
31+
prefix: automatic-clock-outs
32+
handler: src/handlers/automatic-clock-outs/index.js
33+
events:
34+
- timer: ${self:custom.globalSchedule}

0 commit comments

Comments
 (0)