-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.gitlab-ci.yml
137 lines (131 loc) Β· 4.64 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
131
132
133
134
135
136
137
metrics:
before_script:
- echo "nothing to do.."
script:
- echo 'metric_name metric_value' > metrics.txt
artifacts:
reports:
metrics: metrics.txt
stages:
- test
- build
- publish
precommit:
image: mcr.microsoft.com/dotnet/sdk:8.0-alpine
stage: test
except:
- public
before_script:
- export PYTHONUNBUFFERED=1
- apk add --no-cache git build-base python3 python3-dev wget bash nodejs npm && ln -sf python3 /usr/bin/python
- python3 -m ensurepip
- pip3 install --no-cache --upgrade pip setuptools
- python3 -m pip install pre-commit
- dotnet restore "web/web.csproj"
- dotnet --version
script:
- export PATH="$PATH:/root/.dotnet/tools"
- dotnet tool install -g dotnet-format
- npm -g install
# - pre-commit run dotnet-format --all-files
- pre-commit run check-json --all-files
- pre-commit run check-toml --all-files
- pre-commit run check-yaml --all-files
- pre-commit run end-of-file-fixer --all-files
- pre-commit run isort --all-files
- pre-commit run black --all-files
- pre-commit run prettier --all-files
- pre-commit run stylelint --all-files
build_web:
image: mcr.microsoft.com/dotnet/sdk:8.0-alpine
stage: build
except:
- public
script:
- cd "web"
- sed -i '$s/}/,\n"banner_text":{"site_message":"Atlas Test"}}/' appsettings.json
- dotnet publish -r win-x86 --self-contained false -c Release -o out
artifacts:
paths: ['/builds/atlas/web/atlas-dotnet/web/out/']
deploy_test:
image: alpine:latest
stage: publish
except:
- public
dependencies:
- build_web
needs: [build_web]
before_script:
- apk add --no-cache openssh
- eval $(ssh-agent -s)
- echo "$atlas_ssh_key" | ssh-add -
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
# empty folder
- ssh $atlas_ssh_user@$atlas_server "cd C:\inetpub\wwwroot\atlas-test && DEL /Q . && for /d %x in (C:\inetpub\wwwroot\atlas-test\*) do @rd /s /q \"%x\""
# load new site
- scp -r /builds/atlas/web/atlas-dotnet/web/out/* $atlas_ssh_user@$atlas_server:/c:/inetpub/wwwroot/atlas-test/
public:
stage: publish
image: python:3.12
needs:
- job: build_web
artifacts: false
only:
- master
except:
- public
before_script:
- apt-get install -y git
- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh
- ssh-keyscan github.com >> ~/.ssh/known_hosts
- echo "$github_priv_key" | tr -d '\r' | ssh-add -
- git config --global user.email "$GITLAB_USER_EMAIL"
- git config --global user.name "$GITLAB_USER_NAME"
- shopt -s dotglob # include dotfiles in mv
script:
- cd public-publish && python build_public.py
- cd $CI_PROJECT_DIR
- git init
- git remote add origin https://oauth2:${CI_PUSH_TOKEN}@$CI_SERVER_HOST/$CI_PROJECT_PATH.git || git remote set-url origin https://oauth2:${CI_PUSH_TOKEN}@$CI_SERVER_HOST/$CI_PROJECT_PATH.git
- git config user.email "$GITLAB_USER_EMAIL"
- git config user.name "$GITLAB_USER_NAME"
- git add . && git commit -m '[skip ci] public update'
# force to remove history on branch
- export GIT_SSL_NO_VERIFY=1 && git push --force --follow-tags origin HEAD:public
# list changes
- cd ..; rm -rf pub; mkdir pub; cd pub && git init && git remote add origin git@github.com:atlas-bi/atlas-bi-library.git && git pull origin master
- git rm -rf . ; git clean -fxd # remove pub files, except git
- cd $CI_PROJECT_DIR && rm -rf .git
- cd .. && cd pub && mv $CI_PROJECT_DIR/* .
- git status
github:
when: manual
needs:
- job: metrics
artifacts: false
only:
- public # public branch
stage: publish
image: python:3.12
before_script:
- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh
- ssh-keyscan github.com >> ~/.ssh/known_hosts
- echo "$github_priv_key" | tr -d '\r' | ssh-add -
- git config --global user.email "$GITLAB_USER_EMAIL"
- git config --global user.name "$GITLAB_USER_NAME"
- shopt -s dotglob # include dotfiles in mv
script:
- cd ..; rm -rf pub; mkdir pub; cd pub && git init && git remote add origin git@github.com:atlas-bi/atlas-bi-library.git && git pull origin master
- git rm -rf . ; git clean -fxd # remove pub files, except git
- cd $CI_PROJECT_DIR && rm -rf .git
- cd .. && cd pub && mv $CI_PROJECT_DIR/* .
- git status
- git add . && git commit -m "$MESSAGE"
- git status
- git push -u origin master