This guide explains all the commands that the developer needs to execute in order to deploy a new version of any project successfully. This document does not try to explain what is going on the server side, just the "deployer" side.
This will allow you to connect to the servers.
If you don't have already a ssh key, create one as follows:
ssh-keygen -t ed25519 # Recommended to leave it in your home directory. The use of passphrase(password) is optional. You can use ssh agent to avoid to write the password many times in one command.
cd ~/.ssh && ls -al # you should see your new private and public key. The public key ends with .pub
cat YOUR_PUB_KEY # This is your public key. You have to send it to it team so they can configure it in the servers.You can also use the public key to use it Github and Gitlab
This is the configuration for the SSH client so it knows where and how to connect to the servers.
cd ~/.ssh
nano config # copy and paste the content from the config file
chmod 644 config # Change file permissionsgpg --version # Your should have at least version 2.X.X
gpg --full-generate-key # Generate key
# 1. Kind of key? RSA and RSA - It is the default
# 2. What keysize do you want? 4096
# 3. Follow the instrucctions in the screen for the rest of options
gpg --list-keys # list the keys. This is where you get your ID. In ~/.ssh, you have each key in a file. Here all the keys are stored in another structure, so it is harder to export, but you won't need.You need to sign with gpg. So, you have to specify which GPG key you want to use to sign:
[user]
email = your@mail.com
signingkey = YOUR_GPG_ID_KEY # See previous stepMake sure you fulfill all the requirements and you have the [user] option in .git/config as explained before.
git tag # list all tags
git tag -a -s vX # Use same naming structure. If you get an error see *1
git push --tag*1: It might be possible that git cannot sign properly and therefore give you an error. In that case, you can sign the file manually
gpg --status-fd=2 -bsau YOUR_GPG_ID_KEY .git/TAG_EDITMSG
# see more info https://gist.github.com/paolocarrasco/18ca8fe6e63490ae1be23e84a7039374Some websites can change their contents from: source code or CMS content. Therefore, everytime you want to publish a new version you first need to trigger the pipeline manually instead of doing the tag process explained before.
Once you upload the tag in step 1, the CI in gitlab will trigger and a new build will be executed in the special deployment repository linked to the project. You can see all the jobs running in the CI > pipelines repository in Gitlab. Wait until the job is done to proceed with this step.
You can see all the deployments projects in your deployment repository. You need to be a member of the deployment team to have access.
Then, you have to do the same as you did in step 1 but in the deployment repository.
Make sure you fulfill all the requirements and you have the [user] option in .git/config as explained before.
- Wait until the automatic deployment
Once the project is built, then create the tag there. Use the same version name system + your name like
v0.0.6-yourname
git tag # list all tags
git tag -a -s vX # use for example v0.0.6-yourname. Better to use your own name, to know who trigger which deployment version :). If you get an error see *1
git push --tagNow that we have built the project with your signature, we need to move it to the servers.
Make sure you fulfill all the requirements and you have the .ssh/config file as explained before. Also, make sure you have the right permissions to trigger the command using your ssh key. Ask an it-member to change it.
Just trigger the command remotly using the following command in each server:
for deploy in deploy_YOUR_PROJECT@web-{1,2,3,4}; do ssh ${deploy}; done # This changes all the servers at once
# One-by-one. Not recommended.
ssh deploy_YOUR_PROJECT@web-1 # This only changes deployment in the first server!Depending on the project your command will be different. Ask an it-member to know the name of your project.