Automatyczne wdrażanie zmian witryny internetowej
- usługa ciągłej integracji
- hak Git w fazie
post-receive
Usługa ciągłej integracji
Wykonywanie skryptu po wprowadzeniu zmiany do wskazanego repozytorium Git.
Jestem zainteresowany wykorzystaniem systemu Cuirass, który jest używany przez projekt Guix.
Hak Git w fazie post-receive
Wdrażanie zmiany przez odległy serwer po wprowadzeniu zmiany do wskazanego repozytorium Git.
- konto użytkownika posiadające klucze publiczne autoryzujące do wdrażania zmian
w pliku
authorized_keys
- weryfikacja instalacji Jekyll w haku
- wdrożenie zmian w haku
- definicja serwera wdrażającego wśród klientów
- wskazanie serwera witryny internetowej na repozytorium Git
- wprowadzenie zmiany przez klienta
English
- Continuous Integration Service
- Git
post-receive
hook
Continuous Integration Service
Execution of a script after a commit has been pushed to a specified Git repository.
I am interested in using the Cuirass system, which is used by the Guix project.
Git post-receive
hook
Deployment of a change by a remote server after a commit has been pushed to a specified Git repository.
- user account holding public keys authorising deployment of changes in
authorized_keys
file - verification of Jekyll installation in the hook
- deployment of changes in the hook
- definition of deployment server among clients
- pointer in the website server to the Git repository
- change commit by a client
Źródło: jekyllrb.com
Automated Deployment
There are a number of ways to easily automate the deployment of a Jekyll site.
Continuous Integration Service
One of the easiest ways to set up an automated deployment flow is by using a CI.
These services run a script when there’s a commit on your Git repository. You might want this script to build the site, run tests over the output then deploy it to the service of your choice.
We have guides for the following providers:
- GitHub Actions
- Travis CI
- CircleCI
- Buddy
- Razorops CI/CD
Git post-receive hook
To have a remote server handle the deploy for you every time you push changes using Git, you can create a user account which has all the public keys that are authorized to deploy in its
authorized_keys
file. With that in place, setting up the post-receive hook is done as follows:laptop$ ssh deployer@example.com server$ mkdir myrepo.git server$ cd myrepo.git server$ git --bare init server$ cp hooks/post-receive.sample hooks/post-receive server$ mkdir /var/www/myrepo
Next, add the following lines to hooks/post-receive and be sure Jekyll is installed on the server:
#!/bin/bash -l # Install Ruby Gems to ~/gems export GEM_HOME=$HOME/gems export PATH=$GEM_HOME/bin:$PATH TMP_GIT_CLONE=$HOME/tmp/myrepo GEMFILE=$TMP_GIT_CLONE/Gemfile PUBLIC_WWW=/var/www/myrepo git clone $GIT_DIR $TMP_GIT_CLONE BUNDLE_GEMFILE=$GEMFILE bundle install BUNDLE_GEMFILE=$GEMFILE bundle exec jekyll build -s $TMP_GIT_CLONE -d $PUBLIC_WWW rm -Rf $TMP_GIT_CLONE exit
Finally, run the following command on any users laptop that needs to be able to deploy using this hook:
laptops$ git remote add deploy deployer@example.com:~/myrepo.git
Deploying is now as easy as telling nginx or Apache to look at
/var/www/myrepo
and running the following:laptops$ git push deploy master