web-remote/.gitlab-ci.yml

80 lines
2.2 KiB
YAML

image: $CI_REGISTRY/openlp/runners/angular
stages:
- test
- build
- deploy
audit:
stage: test
script:
- yarn install
- yarn audit
except:
- tags
allow_failure: true
lint:
stage: test
script:
- yarn install
- yarn lint
except:
- tags
test:
stage: test
script:
- yarn install
- yarn test --no-progress --no-watch --browsers=ChromiumHeadlessCI
except:
- tags
build-branch:
stage: build
script:
- yarn install
- yarn build --no-progress --configuration production --aot
- export APP_VERSION=`git describe --dirty --tags --long --match '*[0-9]*'`
- 'echo "window.appVersion = \"$APP_VERSION\";" > dist/web-remote/assets/version.js'
artifacts:
paths:
- dist/
only:
- branches
build-tag:
stage: build
script:
- yarn install
- yarn build --no-progress --configuration production --aot
- 'echo "window.appVersion = \"$CI_COMMIT_TAG\";" > dist/web-remote/assets/version.js'
artifacts:
paths:
- dist/
only:
- tags
deploy:
stage: deploy
script:
- cd dist/web-remote
- zip -r ../../remote-$CI_COMMIT_TAG.zip *
- cd ../../
- export CHECK_SUM=`sha256sum remote-$CI_COMMIT_TAG.zip | cut -d' ' -f1`
- export FILE_SIZE=`stat -c '%s' remote-$CI_COMMIT_TAG.zip`
- 'echo -e "{\"latest\": {\"version\": \"$CI_COMMIT_TAG\", \"sha256\": \"$CHECK_SUM\", \"filename\": \"remote-$CI_COMMIT_TAG.zip\", \"size\": $FILE_SIZE}}" > version-$CI_COMMIT_TAG.json'
- mkdir -p ~/.ssh
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- eval $(ssh-agent -s)
- ssh-add ~/.ssh/id_rsa
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh openlp@openlp.io "mkdir -p /home/openlp/sites/get.openlp.org/www/remote/$CI_COMMIT_TAG"
- scp remote-$CI_COMMIT_TAG.zip openlp@openlp.io:/home/openlp/sites/get.openlp.org/www/remote/$CI_COMMIT_TAG/
- scp version-$CI_COMMIT_TAG.json openlp@openlp.io:/home/openlp/sites/get.openlp.org/www/remote/
- ssh openlp@openlp.io "rm /home/openlp/sites/get.openlp.org/www/remote/version.json"
- scp version-$CI_COMMIT_TAG.json openlp@openlp.io:/home/openlp/sites/get.openlp.org/www/remote/version.json
only:
- tags