image: node:14 stages: - build - test - packaging - deploy include: - template: Code-Quality.gitlab-ci.yml variables: SAST_DISABLE_DIND: "true" Minimize_Frontend: stage: build before_script: - yarn install --cache-folder .yarn script: - yarn run build artifacts: expire_in: 2 days paths: - build/ cache: key: ${CI_COMMIT_REF_SLUG} paths: - .yarn/ - node_modules/ Build_Backend: image: golang:latest stage: build script: - cd apiGo - go build -v -o openmediacenter - env GOOS=windows GOARCH=amd64 go build -v -o openmediacenter.exe artifacts: expire_in: 2 days paths: - "./apiGo/openmediacenter*" Frontend_Tests: stage: test before_script: - yarn install --cache-folder .yarn script: - yarn run test artifacts: reports: junit: - ./junit.xml cache: key: ${CI_COMMIT_REF_SLUG} paths: - .yarn/ - node_modules/ Backend_Tests: image: golang:latest stage: test script: - cd apiGo - go get -u github.com/jstemmer/go-junit-report - go test -v ./... 2>&1 | go-junit-report -set-exit-code > report.xml artifacts: when: always reports: junit: ./apiGo/report.xml code_quality: tags: - dind Debian_Server: stage: packaging image: debian script: - vers=$(grep -Po '"version":.*?[^\\]",' package.json | grep -Po '[0-9]+\.[0-9]+\.[0-9]+') # parse the version out of package .json - cd deb - mkdir -p "./OpenMediaCenter/var/www/openmediacenter/videos/" - mkdir -p "./OpenMediaCenter/tmp/" - mkdir -p "./OpenMediaCenter/usr/bin/" - cp -r ../build/* ./OpenMediaCenter/var/www/openmediacenter/ - cp ../apiGo/openmediacenter ./OpenMediaCenter/usr/bin/ - cp ../database.sql ./OpenMediaCenter/tmp/openmediacenter.sql - 'echo "Version: ${vers}" >> ./OpenMediaCenter/DEBIAN/control' - chmod -R 0775 * - dpkg-deb --build OpenMediaCenter - mv OpenMediaCenter.deb OpenMediaCenter-${vers}_amd64.deb artifacts: expire_in: 7 days paths: - deb/OpenMediaCenter-*.deb needs: - Minimize_Frontend - Build_Backend Test_Server: stage: deploy image: luki42/alpineopenssh:latest needs: - Frontend_Tests - Backend_Tests - Debian_Server only: - master script: - eval $(ssh-agent -s) - ssh-add <(echo "$SSH_PRIVATE_KEY") - mkdir -p ~/.ssh - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' - scp deb/OpenMediaCenter-*.deb root@192.168.0.42:/tmp/ - ssh root@192.168.0.42 "DEBIAN_FRONTEND=noninteractive apt-get --reinstall -y -qq install /tmp/OpenMediaCenter-*.deb && rm /tmp/OpenMediaCenter-*.deb" allow_failure: true