Skip to content

Commit c2ea723

Browse files
committed
Initial phpipam action
0 parents  commit c2ea723

File tree

428 files changed

+89495
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

428 files changed

+89495
-0
lines changed

.gitignore

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
10+
# Diagnostic reports (https://nodejs.org/api/report.html)
11+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+
.grunt
31+
32+
# Bower dependency directory (https://bower.io/)
33+
bower_components
34+
35+
# node-waf configuration
36+
.lock-wscript
37+
38+
# Compiled binary addons (https://nodejs.org/api/addons.html)
39+
build/Release
40+
41+
# Dependency directories
42+
jspm_packages/
43+
44+
# Snowpack dependency directory (https://snowpack.dev/)
45+
web_modules/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Optional stylelint cache
57+
.stylelintcache
58+
59+
# Microbundle cache
60+
.rpt2_cache/
61+
.rts2_cache_cjs/
62+
.rts2_cache_es/
63+
.rts2_cache_umd/
64+
65+
# Optional REPL history
66+
.node_repl_history
67+
68+
# Output of 'npm pack'
69+
*.tgz
70+
71+
# Yarn Integrity file
72+
.yarn-integrity
73+
74+
# dotenv environment variable files
75+
.env
76+
.env.development.local
77+
.env.test.local
78+
.env.production.local
79+
.env.local
80+
81+
# parcel-bundler cache (https://parceljs.org/)
82+
.cache
83+
.parcel-cache
84+
85+
# Next.js build output
86+
.next
87+
out
88+
89+
# Nuxt.js build / generate output
90+
.nuxt
91+
dist
92+
93+
# Gatsby files
94+
.cache/
95+
# Comment in the public line in if your project uses Gatsby and not Next.js
96+
# https://nextjs.org/blog/next-9-1#public-directory-support
97+
# public
98+
99+
# vuepress build output
100+
.vuepress/dist
101+
102+
# vuepress v2.x temp and cache directory
103+
.temp
104+
.cache
105+
106+
# Docusaurus cache and generated files
107+
.docusaurus
108+
109+
# Serverless directories
110+
.serverless/
111+
112+
# FuseBox cache
113+
.fusebox/
114+
115+
# DynamoDB Local files
116+
.dynamodb/
117+
118+
# TernJS port file
119+
.tern-port
120+
121+
# Stores VSCode versions used for testing VSCode extensions
122+
.vscode-test
123+
124+
# yarn v2
125+
.yarn/cache
126+
.yarn/unplugged
127+
.yarn/build-state.yml
128+
.yarn/install-state.gz
129+
.pnp.*

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# PHPIPAM Action
2+
3+
This action Spin up a PHPIPAM instance and clean up before action finished.
4+
5+
## Inputs
6+
7+
### `ipam_database_host`
8+
9+
**optional** Database host phpipam connects to. Default: "database"
10+
11+
### `ipam_database_user`
12+
13+
**optional** Database user phpipam needs to authenticate. Default: "phpipam"
14+
15+
### `ipam_database_pass`
16+
17+
**optional** Database password phpipam needs to authenticate Default: "phpipam"
18+
19+
### `ipam_database_name`
20+
21+
**optional** Database name phpipam uses. Default: "phpipam"
22+
23+
### `database_root_password`
24+
25+
**optional** Root password for the database. Default: "root"
26+
27+
## Example usage
28+
29+
```yaml
30+
steps:
31+
- uses: actions/checkout@v2
32+
- uses: codeaffen/[email protected]
33+
with:
34+
ipam_database_host: 'database'
35+
ipam_database_user: 'phpipam'
36+
ipam_database_pass: 'phpipamadmin'
37+
ipam_database_name: 'phpipam'
38+
database_root_password: 'rootpw'
39+
```

action.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: 'PHPIPAM Action'
2+
description: 'Spin up a PHPIPAM instance'
3+
inputs:
4+
ipam_database_host:
5+
description: 'database host phpipam connects to'
6+
required: false
7+
default: "database"
8+
ipam_database_user:
9+
description: 'database user phpipam needs to authenticate'
10+
required: false
11+
default: "phpipam"
12+
ipam_database_pass:
13+
description: 'database password phpipam needs to authenticate'
14+
required: false
15+
default: "phpipamadmin"
16+
ipam_database_name:
17+
description: 'database name phpipam uses'
18+
required: false
19+
default: "phpipam"
20+
database_root_password:
21+
description: 'root password for the database'
22+
required: false
23+
default: "rootpw"
24+
runs:
25+
using: 'node16'
26+
main: 'main.js'
27+
# post: 'post.js'
28+
branding:
29+
icon: package
30+
color: gray-dark

main.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
const core = require('@actions/core');
2+
const compose = require('docker-compose');
3+
const fs = require('fs');
4+
const yaml = require('js-yaml');
5+
6+
const myArgs = process.argv.slice(2);
7+
8+
const composeFile = './services/docker-compose.yml';
9+
const services_exec = './services/exec.yml';
10+
11+
async function up() {
12+
try {
13+
await compose.upAll({ config: composeFile, log: false })
14+
.then(
15+
() => { console.log('compose started')},
16+
err => { core.setFailed(`compose up failed ${err}`)}
17+
);
18+
} catch (error) {
19+
core.setFailed(error.message);
20+
}
21+
}
22+
23+
function down() {
24+
try {
25+
compose.down({ config: composeFile, log: false })
26+
.then(
27+
() => { console.log('compose down')},
28+
err => { core.setFailed(`compose down failed ${err}`)}
29+
);
30+
} catch (error) {
31+
core.setFailed(error.message);
32+
}
33+
}
34+
35+
async function init() {
36+
37+
if (!fs.existsSync(services_exec)) {
38+
console.log('exec.yml not found');
39+
} else {
40+
let container_commands = yaml.load(fs.readFileSync(services_exec, 'utf8'));
41+
42+
for(const cc of container_commands['exec_list']) {
43+
try {
44+
console.log(`executing "${cc.name}" inside "${cc.container}"`);
45+
for(const c of cc['commands'])
46+
{
47+
await compose.exec(cc.container, c, { config: composeFile, log: true })
48+
}
49+
} catch (error) {
50+
core.setFailed(error.message);
51+
}
52+
}
53+
}
54+
}
55+
56+
if (!fs.existsSync(composeFile)) {
57+
console.log(`${composeFile} not exists`);
58+
return
59+
}
60+
61+
switch (myArgs[0]) {
62+
case 'up': {
63+
up();
64+
break;
65+
}
66+
case 'init': {
67+
init();
68+
break;
69+
}
70+
case 'down': {
71+
down();
72+
break;
73+
}
74+
default: {
75+
console.log('staring phpipam in action mode')
76+
up();
77+
setTimeout(init, 30000);
78+
}
79+
}

node_modules/.bin/js-yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)