Skip to content

Commit 5f79da7

Browse files
committed
[All] Javascript-based github actions
1 parent ccbef0b commit 5f79da7

File tree

8 files changed

+64
-21
lines changed

8 files changed

+64
-21
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const system = require('../../system/module');
2+
const core = system.core
3+
4+
const path = require('node:path');
5+
const app = core.getInput('docker_dir')
6+
7+
system.run({
8+
'dir': core.getInput('dir'),
9+
'docker_dir': path.join('/srv/app', app),
10+
'docker_env': 'XDG_CACHE_HOME=' + path.join('/srv/cache', app ? app : 'project'),
11+
'run': core.getInput('run'),
12+
});

elao.app.docker/.manala/github/integration/run/action.yaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,5 @@ inputs:
1515
required: true
1616

1717
runs:
18-
using: composite
19-
steps:
20-
21-
- name: run
22-
uses: ./.manala/github/system/run
23-
with:
24-
dir: ${{ inputs.dir }}
25-
docker_dir: /srv/app${{ inputs.app != '' && format('/{0}', inputs.app) || '' }}
26-
docker_env: >
27-
XDG_CACHE_HOME=/srv/cache/${{ inputs.app != '' && format('{0}', inputs.app) || 'project' }}
28-
run: ${{ inputs.run }}
18+
using: node16
19+
main: action.js
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
package-lock.json

elao.app.docker/.manala/github/system/module/dist/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const core = require('@actions/core');
2+
const exec = require('@actions/exec');
3+
const os = require('node:os');
4+
5+
exports.core = core
6+
7+
exports.run = async ({ dir, docker_dir, docker_env, run } = {}) => {
8+
process.stdout.write('[command]' + run.split(os.EOL, 1)[0] + os.EOL)
9+
// See: https://github.com/actions/toolkit/issues/649
10+
const { stdout } = await exec.getExecOutput('make', ['sh'], {
11+
'cwd': dir,
12+
'input': Buffer.from(run, 'utf-8'),
13+
'env': {
14+
// See: https://github.com/actions/toolkit/issues/1158
15+
...process.env,
16+
'MANALA_DOCKER_COMMAND_DIR': docker_dir,
17+
'MANALA_DOCKER_COMMAND_ENV': docker_env,
18+
},
19+
'silent': true,
20+
});
21+
process.stdout.write(stdout)
22+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"main": "dist/index.js",
3+
"scripts": {
4+
"build": "ncc build index.js --minify --out dist",
5+
"watch": "ncc build index.js --minify --out dist --watch"
6+
},
7+
"dependencies": {
8+
"@actions/core": "1.10.0",
9+
"@actions/exec": "1.1.1"
10+
},
11+
"devDependencies": {
12+
"@vercel/ncc": "0.36.1"
13+
}
14+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const system = require('../module');
2+
const core = system.core
3+
4+
system.run({
5+
'dir': core.getInput('dir'),
6+
'docker_dir': core.getInput('docker_dir'),
7+
'docker_env': core.getInput('docker_env'),
8+
'run': core.getInput('run'),
9+
});

elao.app.docker/.manala/github/system/run/action.yaml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,5 @@ inputs:
1818
required: true
1919

2020
runs:
21-
using: composite
22-
steps:
23-
24-
- name: Run
25-
shell: sh -c "make sh < {0}"
26-
working-directory: ${{ inputs.dir }}
27-
env:
28-
MANALA_DOCKER_COMMAND_DIR: ${{ inputs.docker_dir }}
29-
MANALA_DOCKER_COMMAND_ENV: ${{ inputs.docker_env }}
30-
run: ${{ inputs.run }}
21+
using: node16
22+
main: action.js

0 commit comments

Comments
 (0)