# Meetup Gitlab Bordeaux ![alt text](img/gitlab-logo-gray-rgb.png "logo")
## Agenda
### About me
OpenSource Addict Backend Developer @
-
bonfilsmichael
-
murlock
-
murlock
### Michael Bonfils
## Wordpress - PHP - SQL (mysql/mariadb) - Lot of (security) updates - Lot of plugins updates
## Wordpress ![alt text](./img/wordpress-update.jpeg "fail")
![alt text](./img/hugo-logo.png "logo") `The world’s fastest framework for building websites` - markdown - deploy once - no more update
```bash $ wget hugo.tar.gz $ tar xf hugo.tar.gz $ ./hugo new site www $ cd www $ git init $ git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke $ echo 'theme = "ananke"' >> config.toml $ ../hugo new posts/my-first-post.md $ vi content/posts/my-first-post.md $ ../hugo server -D ``` http://localhost:1313
## Continuous Integration First, we want to save our website ```shell $ git remote add origin git@gitlab.com:murlock/meetup-bordeaux-february-2020.git $ git add . $ git commit -m "Initial commit" $ git push -f -u origin master ``` And create a build script ```shell $ cat <
build.sh hugo -D --enableGitInfo EOF $ chmod +x build.sh $ git add build.sh $ git commit -m "Add build script" ```
## Continuous Integration Create our `.gitlab-ci.yml` ```yaml image: jojomi/hugo stages: - hugo build: stage: hugo script: - ./build.sh ``` https://gitlab.com/murlock/meetup-bordeaux-february-2020/pipelines
## Continuous Integration Let save our static website as artifact by appending to our `build` job ```yaml artifacts: paths: - public/ ``` https://gitlab.com/murlock/meetup-bordeaux-february-2020/pipelines There is no HTML !
## Continuous Integration Theme is not available as runner doesn't fetch submodule by default ```yaml variables: GIT_SUBMODULE_STRATEGY: recursive ``` https://gitlab.com/murlock/meetup-bordeaux-february-2020/pipelines
## Pages The artifacts will be used as source page Just rename `hugo` to `pages` https://gitlab.com/murlock/meetup-bordeaux-february-2020/pages Broken !
## Pages The URL is missing, let's amend our build script: ``` $ cat <
build.sh hugo -D -b "\$1" --enableGitInfo EOF ``` and update our job to : ```yaml - ./build.sh https://murlock.gitlab.io/meetup-bordeaux-february-2020/ ``` https://murlock.gitlab.io/meetup-bordeaux-february-2020
## Merge Request and master We want to use Pages with Merge Request / Branches ```yaml pages: except: - master ``` Protect your master branch
## Variables https://gitlab.com/murlock/meetup-bordeaux-february-2020/-/settings/ci_cd
Use Protected variables
```yaml deploy: image: ubuntu:18.04 only: - master stage: deploy before_script: - apt update -qq - apt install -y -qq curl git openssh-client rsync - curl --location https://github.com/gohugoio/hugo/releases/download/v0.64.1/hugo_0.64.1_Linux-64bit.tar.gz > hugo.tgz - tar xf hugo.tgz --directory /usr/bin - eval $(ssh-agent -s) script: - ./build.sh ${DEPLOY_URL} - echo "${DEPLOY_CERTIFICATE}" | tr -d '\r' | ssh-add - - rsync -e "ssh -o StrictHostKeyChecking=no" --delete -r public/ ${DEPLOY_HOST}:~/public ```
## Site is ready http://vps747547.ovh.net/
### Reference Runner: https://docs.gitlab.com/ce/ci/runners/ Gitlab Pages: https://docs.gitlab.com/ce/user/project/pages/ Let's Encrypt for wildcard: - https://dev.to/nabbisen/let-s-encrypt-wildcard-certificate-with-certbot-plo Presentation: - https://murlock.gitlab.io/meetup-bordeaux-february-2020-slides/
## Questions