Commit 82dcdcc7 authored by Björn Bartels's avatar Björn Bartels
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+9 −0
Original line number Diff line number Diff line
.buildpath
.project
.idea
.setting*
.nyc*

node_modules
vendor
dist

.gitlab-ci.yml

0 → 100644
+113 −0
Original line number Diff line number Diff line
stages:
  - setup
  - build
  - test
  - deploy

variables:
  BUILD_TARGET: httpdocs
  BUILD_LABEL_TMPFILE: build.txt

before_script:
  - if [ -f ${BUILD_LABEL_TMPFILE} ]; then export BUILD_LABEL=`cat ${BUILD_LABEL_TMPFILE}`; fi


init:
  stage: setup
  tags:
    - kunden-web
  before_script:
    - export BUILD_LABEL=$(TZ=Europe/Berlin date +%Y%m%d-%H%M)
  script:
    # save timestamp to file
    - echo $BUILD_LABEL > ${BUILD_LABEL_TMPFILE}
    - echo -e "\n\n\n\e[96mCreated new build label \e[107;30;1m $BUILD_LABEL \e[0m\n\n\n"
    # other init commands
    - whoami
    - pwd
  artifacts:
    paths:
      - ${BUILD_LABEL_TMPFILE}

app-build:
  stage: build
  tags:
    - kunden-web
  dependencies:
    - init
  variables:
    BUILD_INFO_FILE: httpdocs/build.txt
  script:
    # check if a build environment exists and copy it or install a new one if it doesn't
    - if [ -d /build-env_DOES_NOT_EXIT_USE_INSTALL_FOR_NOW/node_modules ] &&  [ -f /build-env/package-lock.json ];
      then echo -e "\e[96mFOUND EXISTING BUILD ENVIRONMENT" && mv /build-env/* ./;
      else echo -e "\e[93mNO EXISTING BUILD ENVIRONMENT - RUNNING INSTALL" && npm install;
      fi
    # list used packages
    - npm ls || true
    # run node build
    - npm run build
    # create build info file
    - echo -e "LABEL=`cat ${BUILD_LABEL_TMPFILE}`" > ${BUILD_INFO_FILE}
    - echo -e "TAG=${CI_COMMIT_TAG}" >> ${BUILD_INFO_FILE}
    - echo -e "COMMIT=${CI_COMMIT_SHA}" >> ${BUILD_INFO_FILE}
    - echo -e "PIPELINE=${CI_PIPELINE_ID}" >> ${BUILD_INFO_FILE}
    # print debug-info
    - cat ${BUILD_INFO_FILE}
    - ls -la ${BUILD_TARGET}
  artifacts:
    paths:
      - ${BUILD_TARGET}


app-tests:
  stage: test
  tags:
    - kunden-web
  dependencies:
    - app-build
  variables:
    BUILD_TEST_COVERAGE_FILE: httpdocs/coverage.xml
  script:
    # check if a build environment exists and copy it or install a new one if it doesn't
    - php -v
    - node -v


rsync:
  stage: deploy
  tags:
    - web-rsync-runner
  dependencies:
    - app-build
    - app-tests
  before_script:
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
    - mkdir -p ~/.ssh
    - eval $(ssh-agent -s)
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
    - ssh-add <(echo "$SSH_STAGING_PRIVATE_KEY")
    - apt-get install rsync
  script:
    - ssh -p22 user@staging.example.com "mkdir -p /_tmp"
    - rsync -rav -e ssh --exclude='.git/' --exclude='.gitlab-ci.yml' --delete-excluded /${BUILD_TARGET}/ user@staging.example.com:/_tmp
    - ssh -p22 user@staging.example.com "mv /${BUILD_TARGET} /${BUILD_TARGET}_save && mv /_tmp /${BUILD_TARGET}"
    - ssh -p22 user@staging.example.com "rm -rf /${BUILD_TARGET}_save"
  only:
    refs:
      - master


ftp-live:
  stage: deploy
  tags:
    - kunden-web
  dependencies:
    - app-build
    - app-tests
  script:
    - 'which lftp || ( apt-get update -qq && apt-get install -y -qq lftp )'
    - lftp -c "set ftp:ssl-allow no; open -u $FTP_USERNAME,$FTP_PASSWORD $FTP_HOST; mirror -Rev ${BUILD_TARGET}/ ./$FTP_PATH/${BUILD_TARGET}  --ignore-time --parallel=10 --exclude-glob .git* --exclude .git/"
  only:
    refs:
      - master

composer.json

0 → 100644
+5 −0
Original line number Diff line number Diff line
{
    "name": "p-ad/web-base",
    "license": "MIT",
    "require": {}
}

httpdocs/index.html

0 → 100644
+0 −0

Empty file added.

package.json

0 → 100644
+11 −0
Original line number Diff line number Diff line
{
  "name": "web-base",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "MIT"
}