OpenMediaCenter/.gitlab-ci.yml
2021-09-26 21:26:32 +02:00

131 lines
3.1 KiB
YAML

image: node:14
stages:
- build_frontend
- build_backend
- test
- packaging
- deploy
Minimize_Frontend:
stage: build_frontend
before_script:
- yarn install --cache-folder .yarn
script:
- yarn run build
- rm build/*/*/*.map
artifacts:
expire_in: 2 days
paths:
- build/
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .yarn/
- node_modules/
Build_Backend:
image: luki42/go-ffmpeg:latest
stage: build_backend
script:
- cd apiGo
- go build -v -tags sharedffmpeg -o openmediacenter
- cp -r ../build/ ./static/
- go build -v -tags static -o openmediacenter_full
- env GOOS=windows GOARCH=amd64 go build -v -tags static -o openmediacenter.exe
needs:
- Minimize_Frontend
artifacts:
expire_in: 2 days
paths:
- "./apiGo/openmediacenter*"
Frontend_Tests:
stage: test
before_script:
- yarn install --cache-folder .yarn
script:
- yarn run test
needs: []
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 install github.com/jstemmer/go-junit-report@v0.9.1
- go test -v ./... 2>&1 | go-junit-report -set-exit-code > report.xml
needs: []
artifacts:
when: always
reports:
junit: ./apiGo/report.xml
lint:
stage: test
before_script:
- yarn install --cache-folder .yarn
script:
- yarn run lint
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .yarn/
- ./node_modules/
artifacts:
reports:
codequality: gl-codequality.json
needs: []
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/ssh:latest
needs:
- Frontend_Tests
- Backend_Tests
- Debian_Server
only:
- master
script:
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | ssh-add -
- 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