0

I'll make a bat file with goes deploy my site on GitHub pages. The repository is heinpauwelyn.github.io and is made with Angular-CLI. To deploy the site I could use this command:

ng github-pages:deploy

This will place everything on the gh-pages branch but it must stand on the master branch! I'm developing on the development branch.

To automate the proceedings of committing, deploying, checkout gh-pages, copy-pasting, checkout master, copy-pasting, committing and checkout development, I've create this bat file named deploy.bat:

git status
git add *
git commit -m "deploy"
git pull
git push

ng github-pages:deploy
git checkout gh-pages 

echo "copy all your files in this folder to a temporary folder outside this repository (except these inside the `.gitignore` file)"
pause

rem must be automatic done by using this xcopy . ..\temp

git checkout master

echo "copy all your file form the temporary folder back into the repository"
pause

rem rmdir /s /q .
rem xcopy ..\temp .

git status
git add *
git commit -m "deploy"
git pull
git push

echo "site is deployed!"

git checkout development

The code will stop on this line: ng github-pages:deploy. I've checked the syntax on Wikipedia and have seen that the colon is a label to skip code from a running batch file. I think this colon gives the bug.

My question is now can I escape the colon from the batch file so that it's not longer a label but a command?


Note

The goal of the batch file is that I just must use one command to deploy my full site. In the package.json file of my project, I use this code:

{
  "scripts": {
    "deploy": "deploy.bat"
  }
}

When the bug will be solved, I just use command below to deploy my site on the master branch.

npm run deploy
H. Pauwelyn
  • 13,575
  • 26
  • 81
  • 144
  • 4
    If I have to bet, `ng` is a batch file. See if [this](http://stackoverflow.com/a/42872282/2861476) can help. – MC ND Mar 18 '17 at 20:04
  • 1
    And in general it is a good idea to enclose parameter strings not consisting of only A-Za-z_ in double quotes. So most likely `call ng.bat "github-pages:deploy"` or `call ng.cmd "github-pages:deploy"` is what you need. Run in a command prompt window `cmd /?` and `call /?` and read the output help pages carefully. – Mofi Mar 18 '17 at 20:41
  • One more hint: It is also a good idea to call other batch files and executables always with file name __and extension__ and if possible also with full path. Then the batch file does not depend on current values of local environment variables `PATHEXT` and `PATH` on execution. Windows command interpreter must run lots of `filename.*` searches on executing your batch file (and hopefully always finds the right file). – Mofi Mar 18 '17 at 20:50
  • 3
    `:` is called a colon, and it only acts as a label if it's the first character on a line. It can't be used to go to another part of the script without a `call` or a `goto`. – SomethingDark Mar 18 '17 at 21:13

1 Answers1

0

It wasn't the colon that gives the bug but because ng is a batch file. Helped answer: Azure Function / Azure Website Custom Deploy Script Ending Prematurely.

After searching and asking this question, I've found the solution that works!

git status
git add *
git commit -m "deploy"
git pull
git push

call ng.cmd "github-pages:deploy"

call git checkout master
call git merge origin/gh-pages --allow-unrelated-histories

dployer.exe rem | This is a little executable file I've written (it's just for changing 
            rem | content of some files)

git add *
git commit -m "deploy bug oke"
git pull
git push

git checkout development

Thanks to @MCND, @Mofi and @SomethingDark for the comments !

Community
  • 1
  • 1
H. Pauwelyn
  • 13,575
  • 26
  • 81
  • 144