Explicitly skip uploads and notifications in third-party repositories. (#13308)
* Explicitly skip uploads and notifications in third-party repositories. This changes how we handle uploads and Slack notifications in our release build workflows so that they are skipped when running in repositories other than our own. This simplifies testing and verification of the core release code by enabling testers to run a mock release build or mock nightly build to completion without worrying about the uploads and slack notifications failing the whole workflow. * Fix conditional.
Austin S. Hemmelgarn committed
Jul 6, 2022 at 16:16 UTC
794ef438dacc5098932afb07424725d37d3ac26e
4 files changed
+25
-8
.github/workflows/build.yml
+11
-2
@@ -80,6 +80,7 @@ jobs:
80
failure()
81
&& startsWith(github.ref, 'refs/heads/master')
82
&& github.event_name != 'pull_request'
83
+ && github.repository == 'netdata/netdata'
84
}}
85
86
build-static: # Build the static binary archives, and store them as artifacts.
@@ -151,6 +152,7 @@ jobs:
152
failure()
153
&& startsWith(github.ref, 'refs/heads/master')
154
&& github.event_name != 'pull_request'
155
+ && github.repository == 'netdata/netdata'
156
}}
157
158
matrix: # Generate the shared build matrix for our build tests.
@@ -220,6 +222,7 @@ jobs:
222
failure()
223
&& startsWith(github.ref, 'refs/heads/master')
224
&& github.event_name != 'pull_request'
225
+ && github.repository == 'netdata/netdata'
226
}}
227
228
prepare-test-images: # Prepare the test environments for our build checks. This also checks dependency handling code for each tested environment.
@@ -319,6 +322,7 @@ jobs:
322
failure()
323
&& startsWith(github.ref, 'refs/heads/master')
324
&& github.event_name != 'pull_request'
325
+ && github.repository == 'netdata/netdata'
326
}}
327
328
source-build: # Test various source build arrangements.
@@ -391,6 +395,7 @@ jobs:
395
failure()
396
&& startsWith(github.ref, 'refs/heads/master')
397
&& github.event_name != 'pull_request'
398
+ && github.repository == 'netdata/netdata'
399
}}
400
401
updater-check: # Test the generated dist archive using the updater code.
@@ -468,6 +473,7 @@ jobs:
473
failure()
474
&& startsWith(github.ref, 'refs/heads/master')
475
&& github.event_name != 'pull_request'
476
+ && github.repository == 'netdata/netdata'
477
}}
478
479
prepare-upload: # Consolidate the artifacts for uploading or releasing.
@@ -534,6 +540,7 @@ jobs:
540
failure()
541
&& startsWith(github.ref, 'refs/heads/master')
542
&& github.event_name != 'pull_request'
543
+ && github.repository == 'netdata/netdata'
544
}}
545
546
artifact-verification-dist: # Verify the regular installer works with the consolidated artifacts.
@@ -582,6 +589,7 @@ jobs:
589
failure()
590
&& startsWith(github.ref, 'refs/heads/master')
591
&& github.event_name != 'pull_request'
592
+ && github.repository == 'netdata/netdata'
593
}}
594
595
artifact-verification-static: # Verify the static installer works with the consolidated artifacts.
@@ -630,12 +638,13 @@ jobs:
638
failure()
639
&& startsWith(github.ref, 'refs/heads/master')
640
&& github.event_name != 'pull_request'
641
+ && github.repository == 'netdata/netdata'
642
}}
643
644
upload-nightly: # Upload the nightly build artifacts to GCS.
645
name: Upload Nightly Artifacts
646
runs-on: ubuntu-latest
638
- if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly'
647
+ if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly' && github.repository == 'netdata/netdata'
648
needs:
649
- updater-check
650
- source-build
@@ -703,7 +712,7 @@ jobs:
712
upload-release: # Create the draft release and upload the build artifacts.
713
name: Create Release Draft
714
runs-on: ubuntu-latest
706
- if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release'
715
+ if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release' && github.repository == 'netdata/netdata'
716
needs:
717
- updater-check
718
- source-build
.github/workflows/docker.yml
+6
-2
@@ -59,6 +59,7 @@ jobs:
59
failure()
60
&& github.event_name != 'pull_request'
61
&& startsWith(github.ref, 'refs/heads/master')
62
+ && github.repository == 'netdata/netdata'
63
}}
64
65
docker-ci:
@@ -114,6 +115,7 @@ jobs:
115
failure()
116
&& github.event_name != 'pull_request'
117
&& startsWith(github.ref, 'refs/heads/master')
118
+ && github.repository == 'netdata/netdata'
119
}}
120
121
normalize-tag: # Fix the release tag if needed
@@ -168,6 +170,7 @@ jobs:
170
uses: docker/setup-buildx-action@v2
171
- name: Docker Hub Login
172
id: login
173
+ if: github.repository == 'netdata/netdata'
174
uses: docker/login-action@v2
175
with:
176
username: ${{ secrets.DOCKER_HUB_USERNAME }}
@@ -177,7 +180,7 @@ jobs:
180
uses: docker/build-push-action@v3
181
with:
182
platforms: linux/amd64,linux/i386,linux/arm/v7,linux/arm64,linux/ppc64le
180
- push: true
183
+ push: ${{ github.repository == 'netdata/netdata' }}
184
tags: ${{ env.tags }}
185
build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
186
- name: Failure Notification
@@ -204,9 +207,10 @@ jobs:
207
failure()
208
&& github.event_name != 'pull_request'
209
&& startsWith(github.ref, 'refs/heads/master')
210
+ && github.repository == 'netdata/netdata'
211
}}
212
- name: Trigger Helmchart PR
209
- if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly'
213
+ if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly' && github.repository == 'netdata/netdata'
214
uses: benc-uk/workflow-dispatch@v1
215
with:
216
token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
.github/workflows/packaging.yml
+6
-3
@@ -94,6 +94,7 @@ jobs:
94
failure()
95
&& github.event_name != 'pull_request'
96
&& startsWith(github.ref, 'refs/heads/master')
97
+ && github.repository == 'netdata/netdata'
98
}}
99
100
version-check:
@@ -149,6 +150,7 @@ jobs:
150
failure()
151
&& github.event_name != 'pull_request'
152
&& startsWith(github.ref, 'refs/heads/master')
153
+ && github.repository == 'netdata/netdata'
154
}}
155
156
build:
@@ -216,7 +218,7 @@ jobs:
218
/netdata/.github/scripts/pkg-test.sh
219
- name: SSH setup
220
id: ssh-setup
219
- if: github.event_name == 'workflow_dispatch'
221
+ if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata'
222
continue-on-error: true
223
uses: shimataro/ssh-key-action@v2
224
with:
@@ -226,7 +228,7 @@ jobs:
228
- name: Upload to packages.netdata.cloud
229
id: package-upload
230
continue-on-error: true
229
- if: github.event_name == 'workflow_dispatch'
231
+ if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata'
232
run: |
233
.github/scripts/package-upload.sh \
234
${{ matrix.repo_distro }} \
@@ -235,7 +237,7 @@ jobs:
237
${{ needs.version-check.outputs.repo }}
238
- name: Upload to PackageCloud
239
id: upload
238
- if: github.event_name == 'workflow_dispatch'
240
+ if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata'
241
shell: bash
242
env:
243
PKG_CLOUD_TOKEN: ${{ secrets.PACKAGE_CLOUD_API_KEY }}
@@ -270,4 +272,5 @@ jobs:
272
failure()
273
&& github.event_name != 'pull_request'
274
&& startsWith(github.ref, 'refs/heads/master')
275
+ && github.repository == 'netdata/netdata'
276
}}
.github/workflows/repoconfig-packages.yml
+2
-1
@@ -75,6 +75,7 @@ jobs:
75
failure()
76
&& github.event_name != 'pull_request'
77
&& startsWith(github.ref, 'refs/heads/master')
78
+ && github.repository == 'netdata/netdata'
79
}}
80
81
build:
@@ -161,7 +162,7 @@ jobs:
162
.github/scripts/package_cloud_wrapper.sh push "${REPO_PREFIX}-repoconfig/${{ matrix.pkgclouddistro }}" "${pkgfile}"
163
done
164
- name: Failure Notification
164
- if: ${{ failure() }}
165
+ if: ${{ failure() && github.repository == 'netdata/netdata' }}
166
uses: rtCamp/action-slack-notify@v2
167
env:
168
SLACK_COLOR: 'danger'