2

I'm working on a project right now that greatly benefits from ionCube. We're using Git for version control. All code in the Master branch gets encrypted with ionCube and moved to a production server. This is very tedious as each time we change something, we have to manually encode the changes with ionCube before they can go live to production. I'm now coding an automation of this.

My idea is to have a script that constantly monitors our master branch for changes. If there's a new commit, it will fetch the changes, encrypt them with ionCube, then commit them back to Github somewhere else so the production server can fetch the encoded changes. My question is: Should the encrypted version be in its own repo or should it just be another branch of the project?

My initial feeling is that it should be its own repo since none of the encrypted files will ever be merged into the codebase.

xendi
  • 2,332
  • 5
  • 40
  • 64
  • Why does the encrypted stuff need to be in Git at all? – ceejayoz Dec 05 '17 at 21:58
  • 1
    Just so that the production server can easily fetch new, production-ready files already encoded. – xendi Dec 05 '17 at 22:00
  • @xendi I'm not familiar with ionCube, just need to confirm: is it possible to encode scripts (or call inoCube) through a shell script? Such as in a shell script detect if your php scripts changed, then encode the scripts. – Marina Liu Dec 06 '17 at 01:51
  • @MarinaLiu-MSFT That is possible, and using ionCube in CI environments is quite common. The OP might want to contact ionCube support for guidance. Disclosure: I an associated with ionCube. – Nick Dec 08 '17 at 11:19
  • @Nick thanks for the confirmation. And xendi, you can encode the changed files automatically through pre-commit hook. – Marina Liu Dec 11 '17 at 09:37

1 Answers1

1

Since it’s possible to encode files through shell scripts, you can use pre-commit hook to encode the changed files automatically before commit the changes. Detail steps as below:

First, rename pre-commit.sample into pre-commit under .git/hooks in your local repo.

Then, add the content as below in pre-commit hook:

#!/bin/sh

for file in $(git diff HEAD --name-only)
do
{
  echo "This is changed file: $file"
  # encode the $file
}
done
git add .
Marina Liu
  • 36,876
  • 5
  • 61
  • 74
  • Thanks, this is interesting but it seems it lists only file that have been modified, not those that have been added. It seems necessary to add another loop with git ls-files --others --exclude-standard – Pierre Jan 19 '19 at 14:34