Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[All] Javascript-based github actions #377

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions elao.app.docker/.manala/github/integration/run/action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const system = require('../../system/module');
const core = system.core

const path = require('node:path');
const app = core.getInput('docker_dir')

system.run({
'dir': core.getInput('dir'),
'docker_dir': path.join('/srv/app', app),
'docker_env': 'XDG_CACHE_HOME=' + path.join('/srv/cache', app ? app : 'project'),
'run': core.getInput('run'),
});
13 changes: 2 additions & 11 deletions elao.app.docker/.manala/github/integration/run/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,5 @@ inputs:
required: true

runs:
using: composite
steps:

- name: run
uses: ./.manala/github/system/run
with:
dir: ${{ inputs.dir }}
docker_dir: /srv/app${{ inputs.app != '' && format('/{0}', inputs.app) || '' }}
docker_env: >
XDG_CACHE_HOME=/srv/cache/${{ inputs.app != '' && format('{0}', inputs.app) || 'project' }}
run: ${{ inputs.run }}
using: node16
main: action.js
2 changes: 2 additions & 0 deletions elao.app.docker/.manala/github/system/module/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
package-lock.json
1 change: 1 addition & 0 deletions elao.app.docker/.manala/github/system/module/dist/index.js

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions elao.app.docker/.manala/github/system/module/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const core = require('@actions/core');
const exec = require('@actions/exec');
const os = require('node:os');

exports.core = core

exports.run = async ({ dir, docker_dir, docker_env, run } = {}) => {
process.stdout.write('[command]' + run.split(os.EOL, 1)[0] + os.EOL)
// See: https://github.com/actions/toolkit/issues/649
const { stdout } = await exec.getExecOutput('make', ['sh'], {
'cwd': dir,
'input': Buffer.from(run, 'utf-8'),
'env': {
// See: https://github.com/actions/toolkit/issues/1158
...process.env,
'MANALA_DOCKER_COMMAND_DIR': docker_dir,
'MANALA_DOCKER_COMMAND_ENV': docker_env,
},
'silent': true,
});
process.stdout.write(stdout)
}
14 changes: 14 additions & 0 deletions elao.app.docker/.manala/github/system/module/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"main": "dist/index.js",
"scripts": {
"build": "ncc build index.js --minify --out dist",
"watch": "ncc build index.js --minify --out dist --watch"
},
"dependencies": {
"@actions/core": "1.10.0",
"@actions/exec": "1.1.1"
},
"devDependencies": {
"@vercel/ncc": "0.36.1"
}
}
9 changes: 9 additions & 0 deletions elao.app.docker/.manala/github/system/run/action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const system = require('../module');
const core = system.core

system.run({
'dir': core.getInput('dir'),
'docker_dir': core.getInput('docker_dir'),
'docker_env': core.getInput('docker_env'),
'run': core.getInput('run'),
});
12 changes: 2 additions & 10 deletions elao.app.docker/.manala/github/system/run/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,5 @@ inputs:
required: true

runs:
using: composite
steps:

- name: Run
shell: sh -c "make sh < {0}"
working-directory: ${{ inputs.dir }}
env:
MANALA_DOCKER_COMMAND_DIR: ${{ inputs.docker_dir }}
MANALA_DOCKER_COMMAND_ENV: ${{ inputs.docker_env }}
run: ${{ inputs.run }}
using: node16
main: action.js