-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
111 lines (103 loc) · 3.5 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
---
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 git@github.com: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 "noreply@weblate.org"
- 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
markdownlint:
stage: lint
image:
name: davidanson/markdownlint-cli2:latest
entrypoint: [""]
script:
- markdownlint-cli2 "src/en/**/*.md"
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