build project
This commit is contained in:
parent
448ac53247
commit
40d34d65d9
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
25
README.md
25
README.md
|
|
@ -1,2 +1,25 @@
|
||||||
# action-env-replacer
|
# action-env-replace
|
||||||
|
|
||||||
|
This action replace all env that starts with APP_ with env value in file
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
|
||||||
|
### `file`
|
||||||
|
|
||||||
|
**Required** The text of the kubeconfig. Default `""`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Example usage
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
uses: git.qtoa.cn/actions/action-env-replacer@0.0.1
|
||||||
|
with:
|
||||||
|
file: 'deployment.yaml'
|
||||||
|
force: true
|
||||||
|
```
|
||||||
|
|
||||||
|
deployment.yaml
|
||||||
|
```
|
||||||
|
name: ${APP_NAME}
|
||||||
|
```
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
name: 'Replace env in file'
|
||||||
|
description: 'replace env in file'
|
||||||
|
inputs:
|
||||||
|
file:
|
||||||
|
description: 'file name'
|
||||||
|
required: true
|
||||||
|
default: ''
|
||||||
|
runs:
|
||||||
|
using: 'node20'
|
||||||
|
main: 'dist/index.js'
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,80 @@
|
||||||
|
{
|
||||||
|
"name": "action-env-replacer",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "action-env-replacer",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/core": "^1.10.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@vercel/ncc": "^0.38.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@actions/core": {
|
||||||
|
"version": "1.10.1",
|
||||||
|
"resolved": "https://registry.npmmirror.com/@actions/core/-/core-1.10.1.tgz",
|
||||||
|
"integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==",
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/http-client": "^2.0.1",
|
||||||
|
"uuid": "^8.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@actions/http-client": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmmirror.com/@actions/http-client/-/http-client-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-q+epW0trjVUUHboliPb4UF9g2msf+w61b32tAkFEwL/IwP0DQWgbCMM0Hbe3e3WXSKz5VcUXbzJQgy8Hkra/Lg==",
|
||||||
|
"dependencies": {
|
||||||
|
"tunnel": "^0.0.6",
|
||||||
|
"undici": "^5.25.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@fastify/busboy": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmmirror.com/@fastify/busboy/-/busboy-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vercel/ncc": {
|
||||||
|
"version": "0.38.1",
|
||||||
|
"resolved": "https://registry.npmmirror.com/@vercel/ncc/-/ncc-0.38.1.tgz",
|
||||||
|
"integrity": "sha512-IBBb+iI2NLu4VQn3Vwldyi2QwaXt5+hTyh58ggAMoCGE6DJmPvwL3KPBWcJl1m9LYPChBLE980Jw+CS4Wokqxw==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"ncc": "dist/ncc/cli.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tunnel": {
|
||||||
|
"version": "0.0.6",
|
||||||
|
"resolved": "https://registry.npmmirror.com/tunnel/-/tunnel-0.0.6.tgz",
|
||||||
|
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/undici": {
|
||||||
|
"version": "5.28.2",
|
||||||
|
"resolved": "https://registry.npmmirror.com/undici/-/undici-5.28.2.tgz",
|
||||||
|
"integrity": "sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==",
|
||||||
|
"dependencies": {
|
||||||
|
"@fastify/busboy": "^2.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmmirror.com/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"name": "action-env-replacer",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"type": "commonjs",
|
||||||
|
"scripts": {
|
||||||
|
"build": "ncc build src/index.js -o dist"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@vercel/ncc": "^0.38.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/core": "^1.10.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
const core = require('@actions/core');
|
||||||
|
const { writeFileSync, readFileSync } = require('fs');
|
||||||
|
try {
|
||||||
|
const file = core.getInput('file');
|
||||||
|
let content = readFileSync(file, { encoding: "utf-8" })
|
||||||
|
const envs = process.env
|
||||||
|
for (const key in envs) {
|
||||||
|
if (key.startsWith("APP_")) {
|
||||||
|
content = content.replace(new RegExp(`\\$\\{\\s*${key}\\s*\\}`), envs[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writeFileSync(file, content)
|
||||||
|
core.info(`replace envs in ${file}`);
|
||||||
|
} catch (error) {
|
||||||
|
core.setFailed(error.message);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue