Merge pull request #45 from stefanzweifel/refactor/switch-to-js

[4.0] Switch to NodeJS Environment (BC)
This commit is contained in:
Stefan Zweifel 2020-02-24 19:49:08 +01:00 committed by GitHub
commit cdb861eda0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 19 deletions

View File

@ -1,16 +0,0 @@
FROM alpine/git:1.0.7
LABEL "com.github.actions.name"="Auto Commit changed files"
LABEL "com.github.actions.description"="Automatically commits files which have been changed during the workflow run and push changes back to remote repository."
LABEL "com.github.actions.icon"="git-commit"
LABEL "com.github.actions.color"="orange"
LABEL "repository"="http://github.com/stefanzweifel/git-auto-commit-action"
LABEL "homepage"="http://github.com/stefanzweifel/git-auto-commit-action"
LABEL "maintainer"="Stefan Zweifel <hello@stefanzweifel.io>"
RUN apk add git-lfs
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["sh", "/entrypoint.sh"]

View File

@ -36,8 +36,8 @@ inputs:
default: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> default: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
runs: runs:
using: 'docker' using: 'node12'
image: 'Dockerfile' main: 'index.js'
branding: branding:
icon: 'git-commit' icon: 'git-commit'

View File

@ -28,7 +28,7 @@ _switch_to_repository() {
} }
_git_is_dirty() { _git_is_dirty() {
[[ -n "$(git status -s)" ]] [ -n "$(git status -s)" ]
} }
# Set up git user configuration # Set up git user configuration

34
index.js Normal file
View File

@ -0,0 +1,34 @@
/**
* Most of this code has been copied from the following GitHub Action
* to make it simpler or not necessary to install a lot of
* JavaScript packages to execute a shell script.
*
* https://github.com/ad-m/github-push-action/blob/fe38f0a751bf9149f0270cc1fe20bf9156854365/start.js
*/
const spawn = require('child_process').spawn;
const path = require("path");
const exec = (cmd, args=[]) => new Promise((resolve, reject) => {
console.log(`Started: ${cmd} ${args.join(" ")}`)
const app = spawn(cmd, args, { stdio: 'inherit' });
app.on('close', code => {
if(code !== 0){
err = new Error(`Invalid status code: ${code}`);
err.code = code;
return reject(err);
};
return resolve(code);
});
app.on('error', reject);
});
const main = async () => {
await exec('bash', [path.join(__dirname, './entrypoint.sh')]);
};
main().catch(err => {
console.error(err);
console.error(err.stack);
process.exit(err.code || -1);
})