From 2143397b7012cf686e1c325c33c6efcc09b8c452 Mon Sep 17 00:00:00 2001 From: Nick Boldt Date: Thu, 4 Feb 2021 09:56:33 -0500 Subject: [PATCH] gh18864 - instead of curl, use GH action invocation (#660) Change-Id: I93157a916f85bc2ef108328a969e5dbc38b67034 Signed-off-by: nickboldt --- .github/workflows/release-che-docs.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-che-docs.yml b/.github/workflows/release-che-docs.yml index a1cb21560..af3843bb5 100644 --- a/.github/workflows/release-che-docs.yml +++ b/.github/workflows/release-che-docs.yml @@ -38,9 +38,23 @@ jobs: else chedocsVersion="${{ github.event.inputs.version }}" fi - cd /tmp - # TODO switch to master branch version, not PR version from https://github.com/eclipse/che-docs/pull/1823 - curl -sSLO https://raw.githubusercontent.com/eclipse/che-docs/f634c1d49b0bc88718dcb593f75d11f45de2ba1c/make-release.sh - chmod +x make-release.sh - # fetch che-docs code, bump antora playbook file, create .x branch if not exist, and create release tag from that branch - ./make-release.sh --repo git@github.com:eclipse/che-docs --version ${chedocsVersion} ${{ github.event.inputs.forceflag }} --trigger-release + + # generic method to call a GH action and pass in a single var=val parameter + invokeAction() { + this_repo=$1 + this_action_name=$2 + this_workflow_id=$3 + this_var=$4 + this_val=$5 + + # can compute using GH API + # workflow_id=$(curl -sSL https://api.github.com/repos/${this_repo}/actions/workflows -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept: application/vnd.github.v3+json" | jq --arg search_field "${this_action_name}" '.workflows[] | select(.name == $search_field).id'); # echo "workflow_id = $workflow_id" + # or just pass it in + workflow_id=$this_workflow_id + + curl -sSL https://api.github.com/repos/${this_repo}/actions/workflows/${workflow_id}/dispatches -X POST -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept: application/vnd.github.v3+json" -d "{\"ref\":\"master\",\"inputs\": {\"${this_var}\":\"${this_val}\"} }" || die_with "[ERROR] Problem invoking action https://github.com/${this_repo}/actions?query=workflow%3A%22${this_action_name// /+}%22" + echo "[INFO] Invoked '${this_action_name}' action ($workflow_id) - see https://github.com/${this_repo}/actions?query=workflow%3A%22${this_action_name// /+}%22" + } + + # invoke action from che-docs repo + invokeAction eclipse/che-docs "Release Che Docs" "5193493" version "${chedocsVersion}"