@cryptotaxi247 / netdata-1 / commits / d0a54068a

Properly handle arguments and responses for triggering Docker builds. (#10545)

This moves the actual cURL command to a script, which both properly handles the required parameters and also checks the results of the call so that it throws an error if triggering the Docker build fails.

Austin S. Hemmelgarn committed Jan 22, 2021 at 09:22 UTC d0a54068a3ba00bcd7b29433dee8894cabf17fa3
2 files changed +21 -12
.travis.yml
+2 -12
@@ -361,12 +361,7 @@ jobs:
361 after_failure: post_message "TRAVIS_MESSAGE" "<!here> Draft release submission failed"
362
363 - name: Trigger Docker image build and publish
364 - script: >-
365 - curl -X POST \
366 - -H 'Accept: application/vnd.github.v3+json' \
367 - -H "Authorization: Bearer ${GITHUB_TOKEN}" \
368 - 'https://api.github.com/repos/netdata/netdata/actions/workflows/docker.yml/dispatches' \
369 - -d '{"ref": "master", "inputs": {"version": "${build_version}"}}'
364 + script: .travis/trigger_docker_build.sh "${GITHUB_TOKEN}" "${BUILD_VERSION}"
365 after_failure: post_message "TRAVIS_MESSAGE" "<!here> Failed to trigger docker build during release" "${NOTIF_CHANNEL}"
366
367 - stage: Trigger deb and rpm package build (release)
@@ -462,12 +457,7 @@ jobs:
457 after_deploy: rm -f .travis/gcs-credentials.json
458
459 - name: Trigger Docker image build and publish
465 - script: >-
466 - curl -X POST \
467 - -H 'Accept: application/vnd.github.v3+json' \
468 - -H "Authorization: Bearer ${GITHUB_TOKEN}" \
469 - 'https://api.github.com/repos/netdata/netdata/actions/workflows/docker.yml/dispatches' \
470 - -d '{"ref": "master", "inputs": {"version": "${build_version}"}}'
460 + script: .travis/trigger_docker_build.sh "${GITHUB_TOKEN}" "${BUILD_VERSION}"
461 after_failure: post_message "TRAVIS_MESSAGE" "<!here> Failed to trigger docker build during nightly release" "${NOTIF_CHANNEL}"
462
463 - stage: Trigger deb and rpm package build (nightly release)
.travis/trigger_docker_build.sh new
+19
@@ -0,0 +1,19 @@
1 +#!/bin/sh
2 +
3 +token="${0}"
4 +version="${1}"
5 +
6 +resp="$(curl -X POST \
7 + -H 'Accept: application/vnd.github.v3+json' \
8 + -H "Authorization: Bearer ${token}" \
9 + "https://api.github.com/repos/netdata/netdata/actions/workflows/docker.yml/dispatches" \
10 + -d "{\"ref\": \"master\", \"inputs\": {\"version\": \"${version}\"}}")"
11 +
12 +if [ -z "${resp}" ]; then
13 + echo "Successfully triggered Docker image build."
14 + exit 0
15 +else
16 + echo "Failed to trigger Docker image build. Output:"
17 + echo "${resp}"
18 + exit 1
19 +fi