master<\/code> branch, too.<\/p>\n\n\n\nThe deployment job looks much like the above one (just insert the code after the code of the staging job):<\/p>\n\n\n
deploy_production:\n stage: deploy\n image: tetraweb\/php:7.1<\/span>\n before_script:\n - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'<\/span>\n - mkdir -p ~\/.ssh\n - eval<\/span> $(ssh-agent -s)\n - '[[ -f \/.dockerenv ]] && echo -e \"Host *\\n\\tStrictHostKeyChecking no\\n\\n\" > ~\/.ssh\/config'<\/span>\n - ssh-add <(echo<\/span> \"$STAGING_PRIVATE_KEY\"<\/span>)\n - apt-get install rsync\n script:\n - ssh -p22 user@example.com \"mkdir -p \/html\/wp-content\/themes\/_tmp\"<\/span>\n - rsync -rav -e ssh --exclude='.git\/'<\/span> --exclude='.gitlab-ci.yml'<\/span> --delete-excluded .\/ user@example.com:\/html\/wp-content\/themes\/_tmp\n - ssh -p22 user@example.com \"mv \/html\/wp-content\/themes\/fbn \/html\/wp-content\/themes\/_old && mv \/html\/wp-content\/themes\/_tmp \/html\/wp-content\/themes\/fbn\"<\/span>\n - ssh -p22 user@example.com \"rm -rf \/html\/wp-content\/themes\/_old\"<\/span>\n only:\n - master<\/code><\/div>Code language:<\/span> PHP<\/span> (<\/span>php<\/span>)<\/span><\/small><\/pre>\n\n\nBecause the before_script<\/code> part is equal to both jobs, we could also move it outside the jobs at the level of stages<\/code>.<\/p>\n\n\n\nAnd that is it.<\/p>\n","protected":false},"excerpt":{"rendered":"
I recently started to deal with Continuous Integration (CI). With that, you can automatically run tasks after pushing to a version control repo, like code testing or deployment. This post shows you how a deployment process to staging and production server can look with GitLab.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","wpf_show_in_dewp_planet_feed":false,"flobn_post_versions":"","lazy_load_responsive_images_disabled":false},"categories":[3],"tags":[],"wp-worthy-pixel":{"ignored":false,"public":"690f08bf21104781b4529c3012c5d752","server":"vg07.met.vgwort.de","url":"https:\/\/vg07.met.vgwort.de\/na\/690f08bf21104781b4529c3012c5d752"},"wp-worthy-type":"normal","_links":{"self":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts\/3473"}],"collection":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/comments?post=3473"}],"version-history":[{"count":4,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts\/3473\/revisions"}],"predecessor-version":[{"id":5899,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts\/3473\/revisions\/5899"}],"wp:attachment":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/media?parent=3473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/categories?post=3473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/tags?post=3473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}