-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
130 lines (122 loc) · 4.36 KB
/
.gitlab-ci.yml
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
---
image: registry.zammad.com/docker/zammad-ruby:stable
workflow:
rules:
# Avoid duplicate branch and MR pipelines for push events to branches with an open MR.
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
when: never
# Don't create branch pipelines for pushes to private branches (as there will also be a MR for them).
- if: $CI_COMMIT_BRANCH =~ /^(private|cherry-pick-|renovate|dependabot)/ && $CI_PIPELINE_SOURCE == "push"
when: never
- when: always
stages:
- pre
- lint
- screenshots
- build
- deploy
push to github:
stage: pre
before_script:
- test -d $HOME/.ssh || mkdir $HOME/.ssh
- ssh-keyscan github.com >> $HOME/.ssh/known_hosts
- eval $(ssh-agent -s)
- echo "$PUSH_TO_GITHUB_SSH_PRIVATE_KEY" | ssh-add -
- ssh-add -l
script:
- git fetch --unshallow
- .gitlab/push_to_github.sh [email protected]:zammad/zammad-org.git
only:
- develop
- stable
# This job will create commits in pipelines pushed from Weblate.
# It re-generates the catalog, and any additional files such as view templates and chat assets.
push translations update commit:
stage: pre
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_COMMIT_MESSAGE =~ /Translations update from translations[.]zammad[.]org/
when: always
- when: never
script:
- apt update && apt install -y --no-install-recommends po4a
- pnpm install
- pnpm i18n
- git status
- git config user.email "[email protected]"
- git config user.name "Weblate"
# TODO drop usage of dedicated access token when CI_JOB_TOKEN support for commit pushing was added to weblate
# https://docs.gitlab.com/ee/ci/jobs/ci_job_token.html#git-push-to-your-project-repository
- git remote add gitlab_origin https://oauth2:${WEBLATE_ACCESS_TOKEN}@${CI_SERVER_FQDN}/${CI_PROJECT_PATH}.git
- git add .
- git status --porcelain | grep "^[MA]" || exit 0 # check if files were added/changed
- 'git commit -m "Maintenance: Update translated files and catalog"'
- git show --stat
- git push gitlab_origin HEAD:$CI_COMMIT_REF_NAME
super linter:
stage: lint
image:
name: github/super-linter:slim-v5
entrypoint: [""]
variables:
FILTER_REGEX_EXCLUDE: .vitepress|pnpm-lock.yaml
script:
- |
if [[ "${CI_DEBUG_TRACE,,}" == "true" || "${CI_COMPONENT_TRACE,,}" == "true" ]]; then
echo "CI Component Trace (I_COMPONENT_TRACE) or GitLab's global trace (CI_DEBUG_TRACE) has been set, debug logging. More info: https://docs.gitlab.com/ee/ci/variables/#enable-debug-logging"
set -xv
SL_LOG_LEVEL="TRACE"
fi
export DISABLE_ERRORS=true #must be set in order to collect output file.
export RUN_LOCAL="true"
export DEFAULT_WORKSPACE=${CI_PROJECT_DIR}
export ANSIBLE_DIRECTORY=$CI_PROJECT_PATH
export LINTER_RULES_PATH=$CI_PROJECT_PATH/.github/linters
export CREATE_LOG_FILE=true
export LOG_FILE=super-linter.log
echo "Running super-linter"
LOG_LEVEL=VERBOSE /action/lib/linter.sh
artifacts:
expose_as: 'Super Linter Test Results'
paths: ['super-linter.log']
screenshots:
stage: screenshots
image: docker
before_script:
- .screenshots/zammad-stack/start.sh
- docker ps
script:
- .screenshots/zammad-stack/screenshots.sh || true # TODO drop this, first run always fails?
- .screenshots/zammad-stack/screenshots.sh
- test -d src/public/screenshots/cypress # check that screenshots were copied from the container
after_script:
- .screenshots/zammad-stack/stop.sh
- docker ps
artifacts:
name: screenshots
expose_as: "Generated Screenshots"
expire_in: 1 week
paths:
- src/public/screenshots/cypress
build:
stage: build
script:
- pnpm install
- pnpm build
artifacts:
name: static-html
expose_as: "Generated Website HTML"
expire_in: 1 week
paths:
- dist
deploy to website:
stage: deploy
script:
- test -d $HOME/.ssh || mkdir $HOME/.ssh
- ssh-keyscan -p $DEPLOYPORT $DEPLOYHOST_COMMUNITY >> $HOME/.ssh/known_hosts
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY_COMMUNITY")
- ls -al
- apt update && apt install -y --no-install-recommends rsync
- rsync -avz --delete -e "ssh -p $DEPLOYPORT" dist/ $DEPLOYUSER_COMMUNITY@$DEPLOYHOST_COMMUNITY:/home/next.zammad.org/pub/
only:
- develop