maccyber / micro-dockerhub-hook

Automatic docker deployment with webhooks
32 stars 22 forks source link

Prebuilt Docker images not reading configuration correctly #55

Open georgearnall opened 3 years ago

georgearnall commented 3 years ago

Does this project still work? Edit: I tried running the repo using npm run start and this works as expected. I think the docker image is old. I rebuilt it without docker and it appears to run fine.

# Installs docker
# RUN apk add --update --no-cache docker py-pip
# RUN apk add bash bash-doc bash-completion
# RUN pip install docker-compose

Does the docker container still work ? I tried to run it on docker using my own script and it didn't work. I tried cloning the repo and using docker-compose and that didn't work either.

Payload:

{
  "push_data": {},
  "repository": {
    "repo_name": "maccyber/tagtest:prod"
  }
}

Response:

maccyber/tagtest:prod does not exist in scripts/index.js

Configuration:

const scripts = {
  'maccyber/testhook': 'hello.sh parameter1 parameter2',
  'maccyber/maccyber.io': 'maccyber.io.sh',
  'maccyber/tagtest:prod': 'tag.sh', // repo/image:tag
  'maccyber/fail': 'fail.sh',
  'anshkathuria/tagtest:release-[0-9.]+': 'tag.sh'
}

module.exports = (repoName, tag) => {
  const hook = Object.keys(scripts)
    .find(key => {
      const regex = new RegExp(`^${key}$`, 'gm')
      const image = tag ? `${repoName}:${tag}` : repoName
      const match = image.match(regex)

      return match && match[0] === image
    })

  return scripts[hook]
}
georgearnall commented 3 years ago

I forked your repo and fixed the issue, I'm not 100% sure what was causing it but after I rebuilt the image it started working as expected. I upgraded to the latest version of node and fixed an issue with spaces in the paths.

https://github.com/georgearnall/micro-dockerhub-hook

I'm going to use my image for now but I might submit a pull request if you're happy with the fixes. All the tests still pass.

I also fixed this issue: https://travis-ci.org/github/maccyber/micro-dockerhub-hook/builds/753184709