-
Notifications
You must be signed in to change notification settings - Fork 44
133 lines (132 loc) · 4.44 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
name: ci
on:
push:
branches: [main, release/*, release]
pull_request:
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
web: ${{ steps.web.outputs.any_changed }}
server: ${{ steps.server.outputs.any_changed }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: changed files for web
id: web
uses: tj-actions/changed-files@v36
with:
files: |
web
.github/workflows/ci.yml
.github/workflows/ci_web.yml
.github/workflows/build_web.yml
.github/workflows/deploy_web_nightly.yml
CHANGELOG.md
- name: changed files for server
id: server
uses: tj-actions/changed-files@v36
with:
files: |
server
.github/workflows/ci.yml
.github/workflows/ci_server.yml
.github/workflows/build_server.yml
.github/workflows/deploy_server_nightly.yml
CHANGELOG.md
ci-web:
needs: prepare
if: needs.prepare.outputs.web == 'true'
uses: ./.github/workflows/ci_web.yml
ci-server:
needs: prepare
if: needs.prepare.outputs.server == 'true'
uses: ./.github/workflows/ci_server.yml
ci:
runs-on: ubuntu-latest
needs:
- ci-web
- ci-server
if: '!failure()'
steps:
- run: echo OK
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" || "$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-web:
needs:
- ci
- ci-web
- ci-collect-info
runs-on: ubuntu-latest
if: ${{!failure() && github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'release' || startsWith(github.ref_name, 'release/'))}}
steps:
- name: Dispatch Web Build
uses: benc-uk/workflow-dispatch@v1
with:
workflow: build_web.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 }}"
}'
build-server:
needs:
- ci
- ci-server
- ci-collect-info
runs-on: ubuntu-latest
if: ${{!failure() && github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'release' || startsWith(github.ref_name, 'release/'))}}
steps:
- name: Dispatch Server Build
uses: benc-uk/workflow-dispatch@v1
with:
workflow: build_server.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 }}"
}'