mirror of
https://github.com/valitydev/build-actions.git
synced 2024-11-06 02:05:17 +00:00
Initial actions (#1)
This commit is contained in:
parent
355198d560
commit
2d815e0819
1
.eslintignore
Normal file
1
.eslintignore
Normal file
@ -0,0 +1 @@
|
||||
dist/
|
30
.eslintrc.json
Normal file
30
.eslintrc.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"root": true,
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"extends": [
|
||||
"plugin:jest/recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"eslint:recommended",
|
||||
"plugin:prettier/recommended",
|
||||
"plugin:github/recommended"
|
||||
],
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 9,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"@typescript-eslint/no-use-before-define": "off",
|
||||
"comma-dangle": "off",
|
||||
"import/no-namespace": "off",
|
||||
"prefer-promise-reject-errors": "off"
|
||||
}
|
||||
}
|
11
.github/dependabot.yml
vendored
Normal file
11
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: /
|
||||
schedule:
|
||||
interval: daily
|
||||
|
||||
- package-ecosystem: npm
|
||||
directory: /
|
||||
schedule:
|
||||
interval: daily
|
30
.github/workflows/build.yml
vendored
Normal file
30
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
name: Build & Test CI
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: lts/*
|
||||
|
||||
- name: Cache dependencies
|
||||
id: cache-deps
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: '**/node_modules'
|
||||
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
||||
|
||||
- name: Install dependencies
|
||||
# install deps only if lockfile has changed
|
||||
if: steps.cache-deps.outputs.cache-hit != 'true'
|
||||
run: yarn install --frozen-lockfile
|
||||
shell: bash
|
||||
|
||||
- name: Run all scripts
|
||||
run: yarn run:all
|
15
.github/workflows/tag-action.yml
vendored
Normal file
15
.github/workflows/tag-action.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
name: Create Tag
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: rbkmoney/action-autotag@v1
|
||||
with:
|
||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
67
.gitignore
vendored
Normal file
67
.gitignore
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
node_modules/
|
||||
|
||||
# Editors
|
||||
.vscode/
|
||||
.idea/
|
||||
*.iml
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Other Dependency directories
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
|
||||
# next.js build output
|
||||
.next
|
11
.prettierrc.js
Normal file
11
.prettierrc.js
Normal file
@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
arrowParens: 'always',
|
||||
bracketSpacing: true,
|
||||
endOfLine: 'lf',
|
||||
printWidth: 120,
|
||||
semi: true,
|
||||
singleQuote: true,
|
||||
tabWidth: 4,
|
||||
trailingComma: 'es5',
|
||||
useTabs: true,
|
||||
};
|
33
README.md
33
README.md
@ -1 +1,34 @@
|
||||
# build-actions
|
||||
Centralized repository for all GitHub Actions used in our CI/CD pipelines
|
||||
|
||||
## Example of use
|
||||
|
||||
An example of using actions in your repository. Create a github action file ```./github/build.yml``` with the following content:
|
||||
```yaml
|
||||
name: Deploy Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: rbkmoney/build-actions/packages/jdk-build@v1.0.0
|
||||
- uses: rbkmoney/build-actions/packages/deploy-docker@v1.0.0
|
||||
with:
|
||||
registry-username: ${{secrets.DOCKER_HUB_USERNAME}}
|
||||
registry-password: ${{secrets.DOCKER_HUB_ACCESS_TOKEN}}
|
||||
```
|
||||
This is how we get the project build and the docker image deploy.
|
||||
|
||||
## Complex actions
|
||||
You can create actions by writing custom code that interacts with your repository in any way you'd like.
|
||||
|
||||
### Types of actions
|
||||
You can build `Docker` container and `JavaScript` actions. Actions require a metadata file to define the inputs, outputs and main entrypoint for your action. The metadata filename must be either action.yml or action.yaml
|
||||
|
||||
An example of creating custom action [dotenv](./packages/dotenv) using `JavaScript`
|
||||
|
11
jest.config.js
Normal file
11
jest.config.js
Normal file
@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest',
|
||||
},
|
||||
verbose: true,
|
||||
};
|
52
package.json
Normal file
52
package.json
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "rbk-build-actions",
|
||||
"version": "1.0.0",
|
||||
"description": "JavaScript Action Template",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"run:all": "yarn workspaces run all",
|
||||
"test": "jest --watchAll",
|
||||
"test:ci": "jest"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/rbkmoney/build-actions.git"
|
||||
},
|
||||
"keywords": [
|
||||
"GitHub",
|
||||
"Actions",
|
||||
"JavaScript"
|
||||
],
|
||||
"author": "v.banin",
|
||||
"private": true,
|
||||
"workspaces": {
|
||||
"packages": [
|
||||
"packages/*"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/github": "^5.0.0",
|
||||
"@actions/io": "^1.0.2",
|
||||
"ramda": "^0.27.1",
|
||||
"dotenv": "^10.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/ramda": "^0.27.30",
|
||||
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
||||
"@typescript-eslint/parser": "^5.4.0",
|
||||
"@vercel/ncc": "^0.25.1",
|
||||
"eslint": "^8.2.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-jest": "^25.2.4",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"eslint-plugin-github": "^4.3.5",
|
||||
"jest": "^26.6.3",
|
||||
"jest-circus": "^26.6.3",
|
||||
"ts-jest": "^26.4.4",
|
||||
"prettier": "^2.1.2",
|
||||
"typescript": "^4.0.5"
|
||||
}
|
||||
}
|
25
packages/deploy-docker/README.md
Normal file
25
packages/deploy-docker/README.md
Normal file
@ -0,0 +1,25 @@
|
||||
# `deploy-docker` - **Github Action**
|
||||
|
||||
This action deploy docker image
|
||||
|
||||
## Input
|
||||
|
||||
| Name | Description |
|
||||
| ------------------ | ---------------------------------------------------------------------------------------------- |
|
||||
| `registry-username`| Username for image registry |
|
||||
| `registry-password`| Password for image registry |
|
||||
| `dokerfile-path` | Path to dockerfile directory |
|
||||
|
||||
## Example Workflow File
|
||||
|
||||
```yaml
|
||||
name: Build maven project and deploy docker image
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
uses: rbkmoney/build-actions/packages/deploy-docker@v1.0.0
|
||||
```
|
29
packages/deploy-docker/action.yml
Normal file
29
packages/deploy-docker/action.yml
Normal file
@ -0,0 +1,29 @@
|
||||
name: "Publish docker image"
|
||||
description: "Pushes build artifacts to DockerHub"
|
||||
inputs:
|
||||
registry-username:
|
||||
description: 'Username for image registry'
|
||||
required: true
|
||||
registry-password:
|
||||
description: 'Password for image registry'
|
||||
required: true
|
||||
dokerfile-path:
|
||||
description: 'Path to dockerfile directory'
|
||||
required: false
|
||||
default: './target'
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- shell: bash
|
||||
run: |
|
||||
echo "IMAGE_NAME=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV
|
||||
|
||||
- shell: bash
|
||||
run: docker build -t "${IMAGE_NAME}:latest" -t "${IMAGE_NAME}:${GITHUB_SHA::8}" ${{inputs.dockerfile-path}}
|
||||
|
||||
- shell: bash
|
||||
run: docker login -u ${{inputs.registry-username}} -p ${{inputs.registry-password}}
|
||||
|
||||
- shell: bash
|
||||
run: docker push --all-tags "${GITHUB_REPOSITORY_OWNER,,}/${REPOSITORY_NAME}"
|
39
packages/dotenv/README.md
Normal file
39
packages/dotenv/README.md
Normal file
@ -0,0 +1,39 @@
|
||||
# `dotenv` - **Github Action**
|
||||
|
||||
It reads the .env file from the root of this repo and provides environment variables to build steps.
|
||||
|
||||
## Input
|
||||
|
||||
| Name | Description |
|
||||
| ---------------- | ----------------------------------------------------------------------------|
|
||||
| `path` | Override the path to the .env file. Default is .env in the repository root. |
|
||||
| `log-variables` | Log variables after reading from the .env file. |
|
||||
| `mask-variables` | Mask values after reading from the .env file. |
|
||||
|
||||
## Output
|
||||
| Name | Description |
|
||||
| ---------------- | --------------------------------------------------------------------------------|
|
||||
| `generic` | Whatever is present in the .env file will be converted into an output variable. |
|
||||
|
||||
|
||||
## Example Usage
|
||||
|
||||
E.g. you have the following .env:
|
||||
```
|
||||
VERSION=1.0
|
||||
AUTHOR=Vitaxa
|
||||
```
|
||||
Then you will have outputs:
|
||||
```
|
||||
{
|
||||
version: "1.0"
|
||||
author: "v.banin"
|
||||
}
|
||||
```
|
||||
|
||||
Call action:
|
||||
```
|
||||
id: dotenv
|
||||
uses: rbkmoney/build-actions/packages/dotenv@v1.0.0
|
||||
```
|
||||
Then you can refer to the env version like this ```${{ steps.dotenv.outputs.version }}```
|
21
packages/dotenv/action.yml
Normal file
21
packages/dotenv/action.yml
Normal file
@ -0,0 +1,21 @@
|
||||
name: 'Dotenv Action'
|
||||
description: 'Load variables from .env file'
|
||||
inputs:
|
||||
path:
|
||||
description: 'the path to the .env file (including file name)'
|
||||
required: true
|
||||
default: '.env'
|
||||
log-variables:
|
||||
description: 'whether to log the variables to output or not'
|
||||
required: false
|
||||
default: 'false'
|
||||
mask-variables:
|
||||
description: 'whether to mask the variables as secrets or not'
|
||||
required: false
|
||||
default: 'false'
|
||||
outputs:
|
||||
generic: # output will be available to future steps
|
||||
description: 'This command will have generic output variables based on .env'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
1908
packages/dotenv/dist/index.js
vendored
Normal file
1908
packages/dotenv/dist/index.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
packages/dotenv/dist/index.js.map
vendored
Normal file
1
packages/dotenv/dist/index.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
87
packages/dotenv/dist/licenses.txt
vendored
Normal file
87
packages/dotenv/dist/licenses.txt
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
@actions/core
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@actions/http-client
|
||||
MIT
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
dotenv
|
||||
BSD-2-Clause
|
||||
Copyright (c) 2015, Scott Motte
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
tunnel
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Koichi Kobayashi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
3910
packages/dotenv/dist/sourcemap-register.js
vendored
Normal file
3910
packages/dotenv/dist/sourcemap-register.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
38
packages/dotenv/lib/dotenv.js
Normal file
38
packages/dotenv/lib/dotenv.js
Normal file
@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.readDotEnv = void 0;
|
||||
const env = __importStar(require("dotenv"));
|
||||
const fs = __importStar(require("fs"));
|
||||
function readEnv(dotenvFile) {
|
||||
if (!fs.existsSync(dotenvFile)) {
|
||||
throw new Error('file does not exist');
|
||||
}
|
||||
const dotenv = env.config({ path: dotenvFile });
|
||||
const returnedMap = {};
|
||||
for (const key in dotenv.parsed) {
|
||||
const value = dotenv.parsed[key];
|
||||
const lowercaseKey = key.toLocaleLowerCase();
|
||||
returnedMap[lowercaseKey] = value;
|
||||
}
|
||||
return returnedMap;
|
||||
}
|
||||
exports.readDotEnv = readEnv;
|
49
packages/dotenv/lib/index.js
Normal file
49
packages/dotenv/lib/index.js
Normal file
@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const dotenv_1 = require("./dotenv");
|
||||
try {
|
||||
const dotenvFile = core.getInput('path');
|
||||
const logVariables = core.getInput('log-variables').toLowerCase() === 'true';
|
||||
const maskVariables = core.getInput('mask-variables').toLowerCase() === 'true';
|
||||
const variables = (0, dotenv_1.readDotEnv)(dotenvFile);
|
||||
if (maskVariables) {
|
||||
for (const key in variables) {
|
||||
const value = variables[key];
|
||||
core.setSecret(value);
|
||||
}
|
||||
}
|
||||
if (logVariables) {
|
||||
core.info(`${variables}`);
|
||||
}
|
||||
else {
|
||||
core.info(`loaded ${Object.keys(variables).length} values into the environment`);
|
||||
}
|
||||
core.setOutput('generic', 'please check for actual outputs');
|
||||
for (const key in variables) {
|
||||
const value = variables[key];
|
||||
core.setOutput(key, value);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
33
packages/dotenv/lib/utils.js
Normal file
33
packages/dotenv/lib/utils.js
Normal file
@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getInput = void 0;
|
||||
const core = __importStar(require("@actions/core"));
|
||||
/**
|
||||
* Retrieve the action inputs.
|
||||
*/
|
||||
function getInput() {
|
||||
const paths = core.getInput('paths', { required: true });
|
||||
return {
|
||||
paths,
|
||||
};
|
||||
}
|
||||
exports.getInput = getInput;
|
14
packages/dotenv/package.json
Normal file
14
packages/dotenv/package.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "@build-actions/dotenv",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"format": "prettier --write **/*.ts",
|
||||
"format-check": "prettier --check **/*.ts",
|
||||
"lint": "eslint src/**/*.ts",
|
||||
"package": "ncc build --source-map --license licenses.txt",
|
||||
"all": "npm run build && npm run format && npm run lint && npm run package"
|
||||
}
|
||||
}
|
19
packages/dotenv/src/dotenv.ts
Normal file
19
packages/dotenv/src/dotenv.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import * as env from 'dotenv';
|
||||
import * as fs from 'fs';
|
||||
|
||||
function readEnv(dotenvFile) {
|
||||
if (!fs.existsSync(dotenvFile)) {
|
||||
throw new Error('file does not exist');
|
||||
}
|
||||
|
||||
const dotenv = env.config({ path: dotenvFile });
|
||||
const returnedMap = {};
|
||||
for (const key in dotenv.parsed) {
|
||||
const value = dotenv.parsed[key];
|
||||
const lowercaseKey = key.toLocaleLowerCase();
|
||||
returnedMap[lowercaseKey] = value;
|
||||
}
|
||||
return returnedMap;
|
||||
}
|
||||
|
||||
export { readEnv as readDotEnv };
|
30
packages/dotenv/src/index.ts
Normal file
30
packages/dotenv/src/index.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import * as core from '@actions/core';
|
||||
import { readDotEnv as dotEnv } from './dotenv';
|
||||
try {
|
||||
const dotenvFile = core.getInput('path');
|
||||
const logVariables = core.getInput('log-variables').toLowerCase() === 'true';
|
||||
const maskVariables = core.getInput('mask-variables').toLowerCase() === 'true';
|
||||
const variables = dotEnv(dotenvFile);
|
||||
|
||||
if (maskVariables) {
|
||||
for (const key in variables) {
|
||||
const value = variables[key];
|
||||
core.setSecret(value);
|
||||
}
|
||||
}
|
||||
|
||||
if (logVariables) {
|
||||
core.info(`${variables}`);
|
||||
} else {
|
||||
core.info(`loaded ${Object.keys(variables).length} values into the environment`);
|
||||
}
|
||||
|
||||
core.setOutput('generic', 'please check for actual outputs');
|
||||
|
||||
for (const key in variables) {
|
||||
const value = variables[key];
|
||||
core.setOutput(key, value);
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
7
packages/dotenv/tsconfig.json
Normal file
7
packages/dotenv/tsconfig.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["src"],
|
||||
"compilerOptions": {
|
||||
"outDir": "./lib"
|
||||
}
|
||||
}
|
28
packages/jdk-build/README.md
Normal file
28
packages/jdk-build/README.md
Normal file
@ -0,0 +1,28 @@
|
||||
# `jdk-build` - **Github Action**
|
||||
|
||||
This action cache maven dependencies, add custom env variables and build maven project
|
||||
|
||||
## Input
|
||||
|
||||
| Name | Description |
|
||||
| ------------------ | ---------------------------------------------------------------------------------------------- |
|
||||
| `jdk-version` | The JDK version to set up. |
|
||||
| `jdk-distribution` | JDK distributor. |
|
||||
| `mvn-args` | Additional maven arguments |
|
||||
|
||||
## Example Workflow File
|
||||
|
||||
```yaml
|
||||
name: Build maven project
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
build-mvn:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Build
|
||||
uses: rbkmoney/build-actions/packages/jdk-build@v1.0.0
|
||||
with:
|
||||
mvn-args: '-DjvmArgs="-Xmx256m"'
|
||||
```
|
41
packages/jdk-build/action.yml
Normal file
41
packages/jdk-build/action.yml
Normal file
@ -0,0 +1,41 @@
|
||||
name: 'Maven build'
|
||||
description: 'Build maven project'
|
||||
inputs:
|
||||
jdk-version:
|
||||
description: 'The jdk version to use'
|
||||
default: '15'
|
||||
required: false
|
||||
jdk-distribution:
|
||||
description: 'The jdk distribution to use'
|
||||
default: 'adopt'
|
||||
required: false
|
||||
mvn-args:
|
||||
description: 'Additional maven arguments'
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: set up JDK
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: ${{ inputs.jdk-version }}
|
||||
distribution: ${{ inputs.jdk-distribution }}
|
||||
|
||||
- name: Cache local Maven repository
|
||||
id: mvn-cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-
|
||||
|
||||
- shell: bash
|
||||
run: |
|
||||
echo "RBK_REPOSITORY_OWNER=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV
|
||||
echo "RBK_REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
|
||||
echo "RBK_DOCKER_REGISTRY=registry.hub.docker.com" >> $GITHUB_ENV
|
||||
|
||||
- shell: bash
|
||||
run: mvn -B clean compile package -Ddockerfile.registry=https://${RBK_DOCKER_REGISTRY} ${{ inputs.mvn-args }}
|
19
tsconfig.json
Normal file
19
tsconfig.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"baseUrl": "./",
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"isolatedModules": true,
|
||||
"lib": ["DOM", "ESNext"],
|
||||
"module": "CommonJS",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": false,
|
||||
"target": "es6"
|
||||
},
|
||||
"include": ["packages"],
|
||||
"exclude": ["node_modules", "packages/**/tests/*"]
|
||||
}
|
Loading…
Reference in New Issue
Block a user