Skip to content

Commit d3746da

Browse files
author
Nikolay Matrosov
committed
Initial commit
0 parents  commit d3746da

30 files changed

+100625
-0
lines changed

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/
2+
lib/
3+
node_modules/
4+
jest.config.js

.eslintrc.json

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"plugins": [
3+
"jest",
4+
"@typescript-eslint"
5+
],
6+
"extends": [
7+
"plugin:github/recommended"
8+
],
9+
"parser": "@typescript-eslint/parser",
10+
"parserOptions": {
11+
"ecmaVersion": 9,
12+
"sourceType": "module",
13+
"project": "./tsconfig.json"
14+
},
15+
"rules": {
16+
"i18n-text/no-en": "off",
17+
"eslint-comments/no-use": "off",
18+
"import/no-namespace": "off",
19+
"sort-imports": [
20+
"off"
21+
],
22+
"no-unused-vars": "off",
23+
"max-len": [
24+
"error",
25+
{
26+
"code": 120
27+
}
28+
],
29+
"@typescript-eslint/no-unused-vars": "error",
30+
"@typescript-eslint/explicit-member-accessibility": [
31+
"error",
32+
{
33+
"accessibility": "no-public"
34+
}
35+
],
36+
"@typescript-eslint/no-require-imports": "error",
37+
"@typescript-eslint/array-type": "error",
38+
"@typescript-eslint/await-thenable": "error",
39+
"@typescript-eslint/ban-ts-comment": "error",
40+
"camelcase": "off",
41+
"@typescript-eslint/consistent-type-assertions": "error",
42+
"@typescript-eslint/explicit-function-return-type": [
43+
"error",
44+
{
45+
"allowExpressions": true
46+
}
47+
],
48+
"@typescript-eslint/func-call-spacing": [
49+
"error",
50+
"never"
51+
],
52+
"@typescript-eslint/no-array-constructor": "error",
53+
"@typescript-eslint/no-empty-interface": "error",
54+
"@typescript-eslint/no-explicit-any": "error",
55+
"@typescript-eslint/no-extraneous-class": "error",
56+
"@typescript-eslint/no-for-in-array": "error",
57+
"@typescript-eslint/no-inferrable-types": "error",
58+
"@typescript-eslint/no-misused-new": "error",
59+
"@typescript-eslint/no-namespace": "error",
60+
"@typescript-eslint/no-non-null-assertion": "warn",
61+
"@typescript-eslint/no-unnecessary-qualifier": "error",
62+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
63+
"@typescript-eslint/no-useless-constructor": "error",
64+
"@typescript-eslint/no-var-requires": "error",
65+
"@typescript-eslint/prefer-for-of": "warn",
66+
"@typescript-eslint/prefer-function-type": "warn",
67+
"@typescript-eslint/prefer-includes": "error",
68+
"@typescript-eslint/prefer-string-starts-ends-with": "error",
69+
"@typescript-eslint/promise-function-async": "error",
70+
"@typescript-eslint/require-array-sort-compare": "error",
71+
"@typescript-eslint/restrict-plus-operands": "error",
72+
"semi": "off",
73+
"@typescript-eslint/semi": [
74+
"error"
75+
],
76+
"@typescript-eslint/type-annotation-spacing": "error",
77+
"@typescript-eslint/unbound-method": "error"
78+
},
79+
"env": {
80+
"node": true,
81+
"es6": true,
82+
"jest/globals": true
83+
}
84+
}

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/** -diff linguist-generated=true

.github/dependabot.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: daily
7+
8+
- package-ecosystem: npm
9+
directory: /
10+
schedule:
11+
interval: daily

.github/workflows/check-dist.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# `dist/index.js` is a special file in Actions.
2+
# When you reference an action with `uses:` in a workflow,
3+
# `index.js` is the code that will run.
4+
# For our project, we generate this file through a build process from other source files.
5+
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
6+
name: Check dist/
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
paths-ignore:
13+
- '**.md'
14+
pull_request:
15+
paths-ignore:
16+
- '**.md'
17+
workflow_dispatch:
18+
19+
jobs:
20+
check-dist:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v2
25+
26+
- name: Set Node.js 12.x
27+
uses: actions/[email protected]
28+
with:
29+
node-version: 12.x
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Rebuild the dist/ directory
35+
run: npm run build
36+
37+
- name: Compare the expected and actual dist/ directories
38+
run: |
39+
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
40+
echo "Detected uncommitted changes after build. See status below:"
41+
git diff
42+
exit 1
43+
fi
44+
id: diff
45+
46+
# If index.js was different than expected, upload the expected version as an artifact
47+
- uses: actions/upload-artifact@v2
48+
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
49+
with:
50+
name: dist
51+
path: dist/

.github/workflows/test.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: 'build-test'
2+
on: # rebuild any PRs and main branch changes
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
- 'releases/*'
8+
9+
jobs:
10+
build: # make sure build/ci work properly
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- run: |
15+
npm install
16+
- run: |
17+
npm run all

.gitignore

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Dependency directory
2+
node_modules
3+
4+
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
lib-cov
24+
25+
# Coverage directory used by tools like istanbul
26+
coverage
27+
*.lcov
28+
29+
# nyc test coverage
30+
.nyc_output
31+
32+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33+
.grunt
34+
35+
# Bower dependency directory (https://bower.io/)
36+
bower_components
37+
38+
# node-waf configuration
39+
.lock-wscript
40+
41+
# Compiled binary addons (https://nodejs.org/api/addons.html)
42+
build/Release
43+
44+
# Dependency directories
45+
jspm_packages/
46+
47+
# TypeScript v1 declaration files
48+
typings/
49+
50+
# TypeScript cache
51+
*.tsbuildinfo
52+
53+
# Optional npm cache directory
54+
.npm
55+
56+
# Optional eslint cache
57+
.eslintcache
58+
59+
# Optional REPL history
60+
.node_repl_history
61+
62+
# Output of 'npm pack'
63+
*.tgz
64+
65+
# Yarn Integrity file
66+
.yarn-integrity
67+
68+
# dotenv environment variables file
69+
.env
70+
.env.test
71+
72+
# parcel-bundler cache (https://parceljs.org/)
73+
.cache
74+
75+
# next.js build output
76+
.next
77+
78+
# nuxt.js build output
79+
.nuxt
80+
81+
# vuepress build output
82+
.vuepress/dist
83+
84+
# Serverless directories
85+
.serverless/
86+
87+
# FuseBox cache
88+
.fusebox/
89+
90+
# DynamoDB Local files
91+
.dynamodb/
92+
93+
# OS metadata
94+
.DS_Store
95+
Thumbs.db
96+
97+
# Ignore built ts files
98+
__tests__/runner/*
99+
lib/**/*
100+
101+
.idea

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
lib/
3+
node_modules/

.prettierrc.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"printWidth": 120,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"singleQuote": true,
6+
"trailingComma": "all",
7+
"bracketSpacing": false,
8+
"arrowParens": "avoid"
9+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Nikolay Matrosov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## GitHub Action to deploy Serverless Function to Yandex Cloud
2+
3+
The action finds or creates Serverless Function in the given folder in Yandex Cloud and deploys new version.
4+
5+
**Table of Contents**
6+
7+
<!-- toc -->
8+
9+
- [Usage](#usage)
10+
- [Permissions](#permissions)
11+
- [License Summary](#license-summary)
12+
13+
<!-- tocstop -->
14+
15+
## Usage
16+
17+
```yaml
18+
- name: Deploy Function
19+
id: sls-func
20+
uses: yc-actions/yc-sls-function@v1
21+
with:
22+
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
23+
bucket: ${{ secrets.BUCKET }}
24+
folder-id: 'b1g*********'
25+
function-name: 'test-function'
26+
runtime: 'nodejs16'
27+
memory: '256Mb'
28+
entrypoint: 'src/main.handler'
29+
environment: |
30+
DEBUG=True
31+
COUNT=1
32+
source: |
33+
./src
34+
package.json
35+
exclude: |
36+
**/*.ts
37+
```
38+
`yc-sa-json-credentials` should contain JSON with authorized key for Service Account. More info in [Yandex Cloud IAM documentation](https://cloud.yandex.ru/docs/container-registry/operations/authentication#sa-json).
39+
40+
See [action.yml](action.yml) for the full documentation for this action's inputs and outputs.
41+
42+
## Permissions
43+
44+
To perform this action, it is required that the service account on behalf of which we are acting has granted the `serverless.functions.admin` role or greater.
45+
46+
## License Summary
47+
48+
This code is made available under the MIT license.

__tests__/.env.template

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
INPUT_YC-SA-JSON-CREDENTIALS=
2+
INPUT_FOLDER-ID=
3+
INPUT_FUNCTION-NAME=
4+
INPUT_RUNTIME=
5+
INPUT_ENTRYPOINT=
6+
GITHUB_REPOSITORY=

0 commit comments

Comments
 (0)