summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: 8100af1ed36974189c4ece9c5c8371c80a2d52f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
stages:
  - lint
  - build
  - docs

.build-master:
  image:
    name: ${CI_DOCKER_IMAGE}
  stage: build
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  before_script:
      - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
      - docker login -u ${DOCKER_HUB_USER}  -p ${DOCKER_HUB_TOKEN}

      - docker run --privileged --rm registry.fakecake.org/docker.io/tonistiigi/binfmt --install all
      - docker buildx create --name mp-builder --driver docker-container --bootstrap --use

  script:
      - BUILD_TIMESTAMP=$(date -d $(echo ${CI_COMMIT_TIMESTAMP} | cut -b 1-10) +%y.%m)

      - docker buildx build
          --push
          --platform linux/amd64,linux/arm64,linux/arm/v7
          --tag ${CI_REGISTRY}/cthulhoo/${CI_JOB_NAME}:${BUILD_TIMESTAMP}-${CI_COMMIT_SHORT_SHA}
          --tag ${CI_REGISTRY}/cthulhoo/${CI_JOB_NAME}:latest
          --tag cthulhoo/${CI_JOB_NAME}:${BUILD_TIMESTAMP}-${CI_COMMIT_SHORT_SHA}
          --tag cthulhoo/${CI_JOB_NAME}:latest
          --build-context app-src=.
          --cache-from type=registry,ref=${CI_REGISTRY}/cthulhoo/${CI_JOB_NAME}:latest
          --cache-to type=inline
          ${BUILD_CONTEXT}

# .build-branch:
#   image:
#     name: ${CI_KANIKO_IMAGE}
#     entrypoint: [""] # kaniko doesn't have /bin/sh
#   stage: build
#   rules:
#     - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
#   script:
#       - /kaniko/executor
#         --context "${BUILD_CONTEXT}"
#         --dockerfile "${DOCKER_DIR}/Dockerfile"
#         --destination "${CI_REGISTRY}/cthulhoo/${NAME}:${CI_COMMIT_BRANCH}-latest"
#         --destination "${CI_REGISTRY}/cthulhoo/${NAME}:${CI_COMMIT_BRANCH}-${CI_COMMIT_SHORT_SHA}"
#         --no-push

phpunit:
  image:
    name: ${CI_DOCKER_IMAGE}
  stage: lint
  rules:
    - if: $CI_COMMIT_BRANCH
      changes:
        - '**/*.php'
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  script:
    - php81 ./vendor/bin/phpunit

eslint:
  image:
    name: ${CI_DOCKER_IMAGE}
  stage: lint
  rules:
    - if: $CI_COMMIT_BRANCH
      changes:
        - '**/*.js'
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  script:
    - npm install
    - npx eslint js plugins

phpstan:
  image:
    name: ${CI_DOCKER_IMAGE}
  stage: lint
  rules:
    - if: $CI_COMMIT_BRANCH
      changes:
        - '**/*.php'
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  script:
    - php81 -d memory_limit=-1 ./vendor/bin/phpstan --memory-limit=2G

ttrss-web-nginx:
  extends: .build-master
  variables:
    BUILD_CONTEXT: ${CI_PROJECT_DIR}/.docker/web-nginx

ttrss-fpm-pgsql-static:
   extends: .build-master
   variables:
     BUILD_CONTEXT: ${CI_PROJECT_DIR}/.docker/app

phpdoc:
  image:
    name: ${CI_DOCKER_IMAGE}
  stage: docs
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      changes:
        - '**/*.php'
  script:
    - php81 /phpDocumentor.phar -d classes -d include -t phpdoc --visibility=public
    - mkdir -p ~/.ssh &&
        cp ${PHPDOC_DEPLOY_SSH_KEY} ~/.ssh/id_ed25519 &&
        chmod 0600 ~/.ssh/id_ed25519
    - rsync -av -e 'ssh -o StrictHostKeyChecking=no' phpdoc/ ${PHPDOC_DEPLOY_HOST}:phpdoc/