Relational Run #21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Relational Run | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| workflow_path: | |
| description: Path of the workflow file to dispatch (e.g. .github/workflows/apply-minio.yml) | |
| required: true | |
| ref: | |
| description: Git ref to run the workflow on (defaults to the ref that triggered this dispatch) | |
| required: false | |
| default: '' | |
| cluster_ref: | |
| description: Cluster reference to pass through to the target workflow | |
| required: true | |
| cluster_password: | |
| description: Cluster password to pass through to the target workflow | |
| required: true | |
| workflow_inputs: | |
| description: JSON object of additional inputs to merge into the dispatch payload | |
| required: false | |
| default: '{}' | |
| permissions: | |
| actions: write | |
| deployments: write | |
| contents: write | |
| jobs: | |
| dispatch: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Dispatch target workflow | |
| uses: actions/github-script@v7 | |
| env: | |
| WORKFLOW_PATH: ${{ inputs.workflow_path }} | |
| WORKFLOW_REF: ${{ inputs.ref }} | |
| CLUSTER_REF: ${{ inputs.cluster_ref }} | |
| CLUSTER_PASSWORD: ${{ inputs.cluster_password }} | |
| WORKFLOW_INPUTS: ${{ inputs.workflow_inputs }} | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const path = process.env.WORKFLOW_PATH; | |
| const refEnv = process.env.WORKFLOW_REF; | |
| const clusterRef = process.env.CLUSTER_REF; | |
| const clusterPassword = process.env.CLUSTER_PASSWORD; | |
| const extraRaw = process.env.WORKFLOW_INPUTS || '{}'; | |
| if (!path) { | |
| core.setFailed('workflow_path is required'); | |
| return; | |
| } | |
| if (!clusterRef) { | |
| core.setFailed('cluster_ref is required'); | |
| return; | |
| } | |
| if (!clusterPassword) { | |
| core.setFailed('cluster_password is required'); | |
| return; | |
| } | |
| const ref = refEnv || context.ref; | |
| let extraInputs = {}; | |
| try { | |
| extraInputs = extraRaw ? JSON.parse(extraRaw) : {}; | |
| } catch (error) { | |
| core.setFailed(`workflow_inputs is not valid JSON: ${error.message}`); | |
| return; | |
| } | |
| core.setSecret(clusterPassword); | |
| const inputs = { | |
| ...extraInputs, | |
| cluster_ref: clusterRef, | |
| cluster_password: clusterPassword, | |
| }; | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: path, | |
| ref, | |
| inputs, | |
| }); |