Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add UI inputs for Update helm charts job #399

Closed
wants to merge 1 commit into from

Conversation

viccuad
Copy link
Member

@viccuad viccuad commented Mar 12, 2024

Description

Fix #307.

Add UI inputs when workflow triggered as workflow_dispatch.

Given that the values can come from repository_dispatch (other repos) or workflow_dispatch (UI button), add a new setvariables job, that sets its job outputs to the corresponding values obtained from the payload of the repository_dispatch or from the inputs of the workflow_dispatch.
It is needed to use job outputs as is the only way to pass values between jobs, as jobs are run in their own VM instances and don't share the env.

Make the following jobs depend on it with needs: setvariables.

The javascript script from actions/github-script cannot read job outputs. Hence, add a step that reads the needs.setvariables.outputs and creates env vars. Consume those env vars in js as process.env.foo.

image

Test

Tested manually from my fork, to the point that the job tries to download the crds asset, where it fails.
See: https://github.com/viccuad/helm-charts/actions/runs/8252069909

Additional Information

Tradeoff

Potential improvement

I don't like the amount of complexity this adds to this workflow.

@viccuad viccuad requested a review from a team as a code owner March 12, 2024 16:20
if: needs.check-update-type.outputs.update_type == 'patch' && !endsWith(needs.check-update-type.outputs.repository, 'kwctl')
permissions:
contents: write
pull-requests: write
steps:
- name: create env vars from needs.setvariables.outputs
# This is neeeded because in scripts, we don't have a way to access the `needs` json object.
# The env vars defined here will be accesible in the scripts under `process.env.foo`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be possible to drop this step, not save the vars as env vars, and in the script parse the needs.setvariables.outputs string into json.
So instead of let version = process.env.version do
let version = JSON.parse( ' ${{ needs.setvariables.outputs }} ' ).version.
But I couldn't get it to work.

Add UI inputs when workflow triggered as `workflow_dispatch`.

Given that the values can come from `repository_dispatch` (other repos)
or `workflow_dispatch` (UI button), add a new `setvariables` job, that
sets its job outputs to the corresponding values obtained from the
payload of the repository_dispatch or from the inputs of the
workflow_dispatch.
It is needed to use job outputs as is the only way to pass values
between jobs, as jobs are run in their own VM instances and don't share
the env.

Make the following jobs depend on it with `needs: setvariables`.

The javascript script from actions/github-script cannot read job
outputs. Hence, add a step that reads the `needs.setvariables.outputs`
and creates env vars. Consume those env vars in js as
`process.env.foo`.

Signed-off-by: Víctor Cuadrado Juan <[email protected]>
@viccuad viccuad force-pushed the main branch 3 times, most recently from a2606a1 to 883ed65 Compare March 13, 2024 09:28
@viccuad viccuad changed the title ci: Add inputs for manually run "Update helm charts" job ci: Add inputs for manually run Update helm charts job Mar 13, 2024
@viccuad viccuad changed the title ci: Add inputs for manually run Update helm charts job ci: Add UI inputs for Update helm charts job Mar 13, 2024
@viccuad viccuad marked this pull request as draft March 13, 2024 11:06
@viccuad
Copy link
Member Author

viccuad commented Mar 13, 2024

Converting to draft in favour of #400.

@viccuad
Copy link
Member Author

viccuad commented Mar 13, 2024

Closing in favour of #400.

@viccuad viccuad closed this Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow triggering the chart update job using Github UI
1 participant