diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index d060c6d..0000000 --- a/Dockerfile +++ /dev/null @@ -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 " - -RUN apk add git-lfs - -COPY entrypoint.sh /entrypoint.sh - -ENTRYPOINT ["sh", "/entrypoint.sh"] diff --git a/action.yml b/action.yml index 4988a84..f6b6077 100644 --- a/action.yml +++ b/action.yml @@ -36,8 +36,8 @@ inputs: default: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> runs: - using: 'docker' - image: 'Dockerfile' + using: 'node12' + main: 'index.js' branding: icon: 'git-commit' diff --git a/entrypoint.sh b/entrypoint.sh index 87b28bc..766759b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -28,7 +28,7 @@ _switch_to_repository() { } _git_is_dirty() { - [[ -n "$(git status -s)" ]] + [ -n "$(git status -s)" ] } # Set up git user configuration diff --git a/index.js b/index.js new file mode 100644 index 0000000..b70f3e0 --- /dev/null +++ b/index.js @@ -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); +})