-
Notifications
You must be signed in to change notification settings - Fork 1
158 lines (157 loc) · 5.72 KB
/
Copy pathci.yml
File metadata and controls
158 lines (157 loc) · 5.72 KB
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
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:
- name: Harden Runner
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: changed files for web
id: web
uses: step-security/changed-files@2e07db73e5ccdb319b9a6c7766bd46d39d304bad # v47.0.5
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: step-security/changed-files@2e07db73e5ccdb319b9a6c7766bd46d39d304bad # v47.0.5
with:
files: |
server/
.github/workflows/ci.yml
.github/workflows/ci_server.yml
.github/workflows/build_server.yml
.github/workflows/deploy_server_nightly.yml
server/.goreleaser.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:
- name: Harden Runner
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit
- 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: Harden Runner
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit
- name: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- 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
permissions:
actions: write
if: ${{!failure() && needs.ci-web.result == 'success' && github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'release' || startsWith(github.ref_name, 'release/'))}}
steps:
- name: Harden Runner
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit
- name: Dispatch Web Build
uses: benc-uk/workflow-dispatch@31e2b3319479a63f0ab15bf800eff9e913504e26 # v1.3.2
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
permissions:
actions: write
if: ${{!failure() && needs.ci-server.result == 'success' && github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'release' || startsWith(github.ref_name, 'release/'))}}
steps:
- name: Harden Runner
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit
- name: Dispatch Server Build
uses: benc-uk/workflow-dispatch@31e2b3319479a63f0ab15bf800eff9e913504e26 # v1.3.2
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 }}"
}'