147 lines
3.3 KiB
YAML
147 lines
3.3 KiB
YAML
# This file is a template, and might need editing before it works on your project.
|
|
# see https://docs.gitlab.com/ce/ci/yaml/README.html for all available options
|
|
|
|
# you can delete this line if you're not using Docker
|
|
image: bash:latest
|
|
|
|
stages:
|
|
- build
|
|
- test
|
|
- deploy
|
|
- restart
|
|
|
|
build:datapacks:
|
|
stage: build
|
|
script:
|
|
- apk add --no-cache zip
|
|
- cd datapacks
|
|
- mkdir out
|
|
- find -maxdepth 1 -type d -not -name ".git" -not -name "out" -not -name "." | xargs -I '{}' sh -c 'cd {} && zip -r ../out/{} .'
|
|
|
|
artifacts:
|
|
paths:
|
|
- ./datapacks/out
|
|
only:
|
|
changes:
|
|
- datapacks/**/*
|
|
- datapacks/*
|
|
- .gitlab-ci.yml
|
|
|
|
build:resourcepack:
|
|
stage: build
|
|
script:
|
|
- apk add --no-cache zip
|
|
|
|
- cd resourcepack
|
|
- mkdir -p ../resourcepack-out
|
|
- zip -r ../resourcepack-out/resourcepack .
|
|
|
|
artifacts:
|
|
paths:
|
|
- ./resourcepack-out
|
|
only:
|
|
changes:
|
|
- resourcepack/**/*
|
|
- resourcepack/*
|
|
- .gitlab-ci.yml
|
|
|
|
deploy:datapacks:
|
|
stage: deploy
|
|
script:
|
|
- 'which ssh-agent || ( apk add --no-cache openssh-client )'
|
|
- apk add --no-cache rsync
|
|
|
|
- eval $(ssh-agent -s)
|
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
|
|
- mkdir -p ~/.ssh
|
|
- chmod 700 ~/.ssh
|
|
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
|
|
- chmod 644 ~/.ssh/known_hosts
|
|
|
|
- cd datapacks
|
|
- rsync --dry-run -avz out/ "$SERVER_HOST":"$WPD_FOLDER/world/datapacks" --delete --exclude bukkit
|
|
|
|
- ssh "$SERVER_HOST" mcrcon -H localhost -p minecraft "minecraft:reload"
|
|
needs:
|
|
- build:datapacks
|
|
|
|
only:
|
|
refs:
|
|
- master
|
|
changes:
|
|
- datapacks/**/*
|
|
- datapacks/*
|
|
- .gitlab-ci.yml
|
|
|
|
deploy:resourcepack:
|
|
stage: deploy
|
|
script:
|
|
- 'which ssh-agent || ( apk add --no-cache openssh-client )'
|
|
- apk add --no-cache rsync
|
|
|
|
- eval $(ssh-agent -s)
|
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
|
|
- mkdir -p ~/.ssh
|
|
- chmod 700 ~/.ssh
|
|
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
|
|
- chmod 644 ~/.ssh/known_hosts
|
|
|
|
- cd resourcepack-out
|
|
- SHASUM=$(sha1sum resourcepack.zip | awk '{ print $1 }')
|
|
- ssh "$SERVER_HOST" sed -i "s/resource-pack-sha1=.*/resource-pack-sha1=$SHASUM/" "$WPD_FOLDER/server.properties"
|
|
needs:
|
|
- build:resourcepack
|
|
only:
|
|
refs:
|
|
- master
|
|
changes:
|
|
- resourcepack/**/*
|
|
- resourcepack/*
|
|
- .gitlab-ci.yml
|
|
|
|
pages:
|
|
stage: deploy
|
|
script:
|
|
- mkdir public
|
|
- mv resourcepack-out/resourcepack.zip public/dodsorfas_resources.zip
|
|
artifacts:
|
|
paths:
|
|
- public
|
|
only:
|
|
refs:
|
|
- master
|
|
changes:
|
|
- resourcepack/**/*
|
|
- resourcepack/*
|
|
- .gitlab-ci.yml
|
|
needs:
|
|
- build:datapacks
|
|
|
|
|
|
|
|
restart:
|
|
stage: restart
|
|
|
|
script:
|
|
- echo RESTARTING
|
|
- 'which ssh-agent || ( apk add --no-cache openssh-client )'
|
|
|
|
- eval $(ssh-agent -s)
|
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
|
|
- mkdir -p ~/.ssh
|
|
- chmod 700 ~/.ssh
|
|
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
|
|
- chmod 644 ~/.ssh/known_hosts
|
|
|
|
- ssh "$SERVER_HOST" mcrcon -H localhost -p minecraft "save-all restart"
|
|
|
|
only:
|
|
refs:
|
|
- master
|
|
changes:
|
|
- resourcepack/**/*
|
|
- resourcepack/*
|
|
- .gitlab-ci.yml
|
|
needs:
|
|
- deploy:resourcepack
|
|
- deploy:datapacks |