This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
168 lines (168 loc) · 5.54 KB
/
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: ci
on:
push:
branches: [main, release]
pull_request:
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
plugin: ${{ steps.plugin.outputs.any_changed }}
server: ${{ steps.server.outputs.any_changed }}
tools: ${{ steps.tools.outputs.any_changed }}
worker: ${{ steps.worker.outputs.any_changed }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: changed files for plugin
id: plugin
uses: tj-actions/changed-files@v36
with:
since_last_remote_commit: true
files: |
plugin
.github/workflows/ci-plugin.yml
.github/workflows/ci-plugin-version-update.yml
CHANGELOG.md
- name: changed files for server
id: server
uses: tj-actions/changed-files@v36
with:
since_last_remote_commit: true
files: |
server
.github/workflows/ci-server.yml
.github/workflows/build-server.yml
.github/workflows/deploy-server-dev.yml
.github/workflows/deploy-server-prod.yml
- name: changed files for tools
id: tools
uses: tj-actions/changed-files@v36
with:
since_last_remote_commit: true
files: |
tools
.github/workflows/ci-tools.yml
- name: changed files for worker
id: worker
uses: tj-actions/changed-files@v36
with:
since_last_remote_commit: true
files: |
worker
.github/workflows/ci-worker.yml
.github/workflows/build-worker.yml
.github/workflows/deploy-worker-dev.yml
.github/workflows/deploy-worker-prod.yml
ci-plugin:
needs: prepare
if: ${{ !failure() && needs.prepare.outputs.plugin == 'true' }}
uses: ./.github/workflows/ci-plugin.yml
ci-server:
needs: prepare
if: ${{ !failure() && needs.prepare.outputs.server == 'true' }}
uses: ./.github/workflows/ci-server.yml
ci-worker:
needs: prepare
if: ${{ !failure() && needs.prepare.outputs.worker == 'true' }}
uses: ./.github/workflows/ci-worker.yml
ci-tools:
needs: prepare
if: ${{ !failure() && needs.prepare.outputs.tools == 'true' }}
uses: ./.github/workflows/ci-tools.yml
with:
release_tools: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
ci:
runs-on: ubuntu-latest
needs:
- ci-plugin
- ci-server
- ci-tools
- ci-worker
if: '!failure()'
steps:
- run: echo OK
build-server:
needs: ci-server
if: ${{ success() && github.event_name == 'push' && github.ref_name == 'main' }}
uses: ./.github/workflows/build-server.yml
build-worker:
needs: ci-worker
if: ${{ success() && github.event_name == 'push' && github.ref_name == 'main' }}
uses: ./.github/workflows/build-worker.yml
ci-collect-info:
name: Collect information
needs: ci
if: '!failure()'
runs-on: ubuntu-latest
outputs:
sha_short: ${{ steps.info.outputs.sha_short || 'blank' }}
new_tag: ${{ steps.info.outputs.new_tag || 'blank' }}
new_tag_short: ${{ steps.info.outputs.new_tag_short || 'blank' }}
name: ${{ steps.info.outputs.name || 'blank' }}
steps:
- name: checkout
uses: actions/checkout@v3
- name: Fetch tags
run: git fetch --prune --unshallow --tags
- name: Get info
id: info
# The tag name should be retrieved lazily, as tagging may be delayed.
env:
BRANCH: ${{github.ref_name}}
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
echo "BRANCH=$BRANCH"
if [[ "$BRANCH" = "release" ]]; then
TAG=$(git tag --points-at HEAD)
if [[ ! -z "$TAG" ]]; then
echo "::set-output name=new_tag::$TAG"
echo "::set-output name=new_tag_short::${TAG#v}"
else
echo "::set-output name=name::rc"
fi
else
echo "::set-output name=name::nightly"
fi
- name: Show info
env:
SHA_SHORT: ${{ steps.info.outputs.sha_short }}
NEW_TAG: ${{ steps.info.outputs.new_tag }}
NEW_TAG_SHORT: ${{ steps.info.outputs.new_tag_short }}
NAME: ${{ steps.info.outputs.name }}
run: echo "sha_short=$SHA_SHORT, new_tag=$NEW_TAG, new_tag_short=$NEW_TAG_SHORT, name=$NAME"
build-plugin:
needs:
- prepare
- ci
- ci-plugin
- ci-collect-info
runs-on: ubuntu-latest
if: ${{!failure() && needs.prepare.outputs.plugin == 'true' && github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'release')}}
steps:
- name: Dispatch Plugin Build
uses: benc-uk/workflow-dispatch@v1
with:
workflow: build-plugin.yml
inputs: |
{
"sha_short": "${{ needs.ci-collect-info.outputs.sha_short }}",
"new_tag": "${{ needs.ci-collect-info.outputs.new_tag }}",
"new_tag_short": "${{ needs.ci-collect-info.outputs.new_tag_short }}",
"name": "${{ needs.ci-collect-info.outputs.name }}",
"sha": "${{ github.sha }}"
}
deploy-server-dev:
needs: build-server
runs-on: ubuntu-latest
steps:
- name: Dispatch deployment
uses: peter-evans/repository-dispatch@v2
with:
event-type: deploy-server-dev
deploy-worker-dev:
needs: build-worker
uses: ./.github/workflows/deploy-worker-dev.yml
with:
use_local: true