-
Notifications
You must be signed in to change notification settings - Fork 27
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
Specify bucket-path
when github.head_ref
is not set
#160
Conversation
a9fcacb
to
976032f
Compare
In the workflow we're executing the `thesis/[email protected]` action. One of its inputs is `bucket-path`, which is an optional input and is used to configure bucket path. If in the workflow step executing the action we don't use the `bucket-path` property, the action will set its `bucket-path` input to the default value which is `.`. This is the value that we want to use when workflow is triggered manually or by merge to main. Previously we thought that setting the action to use `bucket-name: ${{ github.head_ref }}` property would do the trick of using `.` for `workflow_dispatch` and `push` events and using `head_ref` for `pull_request` events (because we thougt the default value will be used when `bucket-name: ` (without a value) is used in the action. But this turned out to not be truth. When we use `bucket-name: ` the behavior is different than when we don't provide the `bucket-name` property at all. In the first case we don't see the `bucket-name` property in the runner's log, in the second case we see the property populated with the default `.` value. Not having `bucket-name` property in the runner results in wrong behavior of the action (order of the inputs gets messed up and the address of bucket gets resolved to gs://<BUCKETNAME>/<BUILDFOLDER>". As a solution we add a `set-bucket-path` step which creates an output which value is either `.` or `github.head_ref`, depending if the latter is configured. We then use this output as value of `bucket-path` parameter of action `thesis/[email protected]`. Read more about how runner handles empty values here: actions/runner#924.
976032f
to
47fa501
Compare
- name: Deploy to GCP | ||
uses: thesis/[email protected] | ||
with: | ||
service-key: ${{ inputs.gcpServiceKey }} | ||
project: ${{ env.GOOGLE_PROJECT_ID }} | ||
bucket-name: ${{ inputs.gcpBucketName }} | ||
bucket-path: ${{ github.head_ref }} | ||
bucket-path: ${{ steps.set-bucket-path.outputs.bucket-path }} |
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.
Another solution would be to define gcpBucketPath
with the default: .
and expect the value to be provided in the caller.
bucket-path: ${{ steps.set-bucket-path.outputs.bucket-path }} | |
bucket-path: ${{ inputs.gcpBucketPath }} |
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.
Yeah, that could work, as long as we make sure that the gcpBucketPath
will not have the empty value. In our current use case (using action to build dashboard) it's not problematic. I'll prepare the change.
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.
See fdcd76f. Unfortunately I had to split the Build
step to two steps, depending on condition. Couldn't think of a cleaner solution.
Input is introduced as a dfferent approach to the problem tackled in commit 47fa501. We needed to ensure that `[email protected]` action does not get empty inputs.
…o-bucket-action Specify `bucket-path` when `github.head_ref` is not set In the workflow we're executing the `thesis/[email protected]` action. One of its inputs is `bucket-path`, which is an optional input and is used to configure bucket path. If in the workflow step executing the action we don't use the `bucket-path` property, the action will set its `bucket-path` input to the default value which is `.`. This is the value that we want to use when workflow is triggered manually or by merge to main. Previously we thought that setting the action to use `bucket-name: ${{ github.head_ref }}` property would do the trick of using `.` for `workflow_dispatch` and `push` events and using `head_ref` for `pull_request` events (because we thougt the default value will be used when `bucket-name: ` (without a value) is used in the action. But this turned out to not be truth. When we use `bucket-name: ` the behavior is different than when we don't provide the `bucket-name` property at all. In the first case we don't see the `bucket-name` property in the runner's log, in the second case we see the property populated with the default `.` value. Not having `bucket-name` property in the runner results in wrong behavior of the action (order of the inputs gets messed up and the address of bucket gets resolved to gs://<BUCKETNAME>/<BUILDFOLDER>". As a solution we add a `set-bucket-path` step which creates an output which value is either `.` or `github.head_ref`, depending if the latter is configured. We then use this output as value of `bucket-path` parameter of action `thesis/[email protected]`. Read more about how runner handles empty values here: actions/runner#924.
In the workflow we're executing the
thesis/[email protected]
action. One of its inputs is
bucket-path
, which is an optionalinput and is used to configure bucket path.
If in the workflow step executing the action we don't use the
bucket-path
property, the action will set itsbucket-path
input tothe default value which is
.
. This is the value that we want to usewhen workflow is triggered manually or by merge to main.
Previously we thought that setting the action to use
bucket-name: ${{ github.head_ref }}
property would do the trick ofusing
.
forworkflow_dispatch
andpush
events and usinghead_ref
forpull_request
events (because we thougt the defaultvalue will be used when
bucket-name:
(without a value) is used inthe action. But this turned out to not be truth. When we use
bucket-name:
the behavior is different than when we don't provide thebucket-name
property at all. In the first case we don't see thebucket-name
property in the runner's log, in the second case we seethe property populated with the default
.
value.Not having
bucket-name
property in the runner results in wrongbehavior of the action (order of the inputs gets messed up and the
address of bucket gets resolved to gs:///".
As a solution we add a
set-bucket-path
step which creates an outputwhich value is either
.
orgithub.head_ref
, depending if thelatter is configured. We then use this output as value of
bucket-path
parameter of action
thesis/[email protected]
.Read more about how runner handles empty values here:
actions/runner#924.