-
Notifications
You must be signed in to change notification settings - Fork 16
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, refactor and drop need for crds_asset_id
#400
Conversation
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]>
Instead of consuming the crds_asset_id from workflow inputs, query the repos to obtain the asset id, and use that id to download the CRDs.tar.gz. Signed-off-by: Víctor Cuadrado Juan <[email protected]>
Also, we don't need a js script to set them. Signed-off-by: Víctor Cuadrado Juan <[email protected]>
This simplifies testing, one can create /tmp/crds-{controller,audit-scanner}.tar.gz and run the script locally. Signed-off-by: Víctor Cuadrado Juan <[email protected]>
Signed-off-by: Víctor Cuadrado Juan <[email protected]>
Update helm charts
job, refactor and drop need for crds_asset_id
core.exportVariable("UPDATECLI_CHART_VERSION", context.payload.client_payload.version) | ||
- 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` |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's leave it around
Signed-off-by: Víctor Cuadrado Juan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the fix
core.exportVariable("UPDATECLI_CHART_VERSION", context.payload.client_payload.version) | ||
- 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` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's leave it around
Description
Fix #307
Changes:
workflow_dispatch
.Given that the values can come from
repository_dispatch
(other repos) orworkflow_dispatch
(UI button), add a newsetvariables
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 asprocess.env.foo
.update_cli/scripts/install_crds.sh
.Test
Major/minor release update run: https://github.com/viccuad/helm-charts/actions/runs/8263364335
Patch release update run: https://github.com/viccuad/helm-charts/actions/runs/8263508789/job/22605107087
Also, tested
updatecli/scripts/install_crds.sh
locally, with various/tmp/crds-{controller,audit-scanner}.tar.gz
.Additional Information
Tradeoff
Potential improvement
I don't like the added complexity created by adding the workflow_dispatch
inputs
, and needing to pass it to the js scripts via GH env vars, but it is what it is.About the refactors, I'm happy splitting the commits in several PRs. I tested it altogether to save time. If they aren't wanted they can be dropped, or we can go with #399.