Last active
April 7, 2021 13:02
-
-
Save michidk/47460dc594c441061a5b82fe1415aac7 to your computer and use it in GitHub Desktop.
Gitlab deploy to branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- build | |
- deploy | |
build: | |
stage: build | |
image: node:11 | |
before_script: | |
- npm install --progress=false --unsafe-perm | |
script: | |
- npm run build | |
artifacts: | |
expire_in: 100 yrs | |
paths: | |
- public | |
cache: | |
paths: | |
- node_modules/ | |
deploy: | |
stage: deploy | |
only: | |
- master | |
image: debian:stable | |
before_script: | |
- apt-get update | |
- apt-get install -y git | |
- mkdir -p ~/.ssh | |
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa | |
- chmod 600 ~/.ssh/id_rsa | |
- ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts | |
- git config --global user.email "[email protected]" | |
- git config --global user.name "GitLab CI" | |
script: | |
- git clone --depth 1 --single-branch -b deploy [email protected]:yourname/yourrepo.git deploy | |
- mv deploy/.git deploy-.git | |
- rm -rf deploy | |
- mkdir deploy | |
- mv deploy-.git deploy/.git | |
- cd deploy | |
- cp -r ../public/* . | |
- git add . | |
- git diff --staged --quiet || git commit -m "Update pages" | |
- git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment