Skip to content

ci: Copy 7.73.0 csv to main (#1746) #93

ci: Copy 7.73.0 csv to main (#1746)

ci: Copy 7.73.0 csv to main (#1746) #93

#
# Copyright (c) 2019-2021 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
# This Workflow creates PRs for the release of the latest che-docs
name: Release che docs
on:
# manual trigger if required
workflow_dispatch:
inputs:
version:
description: 'The version that is going to be released. Should be in format 7.y.z'
required: true
default: '7.y.z'
forceflag:
description: 'To force creation of .x branch, use --force flag here'
default: ''
# trigger on commit to main branch of new CSVs, eg., https://github.com/eclipse-che/che-operator/pull/571/files
push:
branches:
- main
paths:
- 'version/version.go'
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install yq
run: |
python -m pip install --upgrade pip
pip install yq
- name: Release che docs PRs
run: |
hub version
git config --global user.name "Mykhailo Kuznietsov"
git config --global user.email "mkuznets@redhat.com"
export GITHUB_TOKEN=${{ secrets.CHE_BOT_GITHUB_TOKEN }}
set -e
# if not run manually, need to compute che docs version from latest released CSV
if [[ "${{ github.event.inputs.version }}" == "" ]] || [[ "${{ github.event.inputs.version }}" == "7.y.z" ]]; then
chedocsVersion=$(grep Version version/version.go | cut -d \" -f2)
else
chedocsVersion="${{ github.event.inputs.version }}"
fi
# 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}\"} }"
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}"