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

Feat/andrews actions #67

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open

Feat/andrews actions #67

wants to merge 41 commits into from

Conversation

andrewhaller
Copy link

No description provided.

runs:
using: composite
steps:
- name: Download github cli

Choose a reason for hiding this comment

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

is there a reason to install the GH CLI at runtime? github-hosted runners should have it installed already

Copy link
Author

Choose a reason for hiding this comment

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

Yeah a github hosted runner would be idea. The repo being downloaded is this terraform-pipeline-executor project written in go. What it's doing under the hood requires the authentications in our self hosted runner.

Choose a reason for hiding this comment

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

ah ok, so this is intended to be ran on self-hosted runners. A pattern I've seen for these types of actions is to check if the tool is already present, and only install if it's not present. If this action is only for use on self-hosted runners then maybe that's overkill, but it would be helpful to make it very obvious that the action shouldn't be used on gh-hosted runners. (maybe that's true of this entire repo and I just missed it?)

Copy link
Author

Choose a reason for hiding this comment

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

Yeah they're pretty much all meant to be used in a situation where you have to use a self-hosted a runner. The discover-changed action is the only one that's used in a gh hosted runner. I could check for prior existence, however to be prudent, I would also need to check if the version of an already-present binary matches, as the user might want to override the version already installed. That said, for our specific case, if I had it my way, I would have control of the runner image and make sure the gh cli was on there to begin with. I think I'm landing on explaining the intent of use in the README

Copy link
Author

Choose a reason for hiding this comment

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

I could also add a skip-gh-if-already-present boolean option, whereby if it's present, and the user does not care about the version, then to skip the download of gh.

Copy link
Author

Choose a reason for hiding this comment

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

I ended up doing away with gc cli altogether, and figured out the correct way to do a curl request on private repo.

run: |
export RELEASE_TAG=$(echo "${RELEASE_NAME}" | sed s/^v//g)
printf "Downloading release '%s' from repo '%s' ...\n" "${RELEASE_NAME}" "${GITHUB_REPO_OWNER}/${GITHUB_REPO}"
./gh release download --repo "${GITHUB_REPO_OWNER}/${GITHUB_REPO}" "${RELEASE_NAME}" -p "${GITHUB_REPO}_${RELEASE_TAG}_${DOWNLOAD_FORMAT_EXT}"

Choose a reason for hiding this comment

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

I'm lacking context on what this action is for, but this pattern (-p) seems very focused, while the action name implies it's fairly generic. Should the entire pattern be an input parameter?

Copy link
Author

Choose a reason for hiding this comment

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

The -p is "Download only assets that match a glob pattern" from this documentation https://cli.github.com/manual/gh_help_reference (search for "gh release download" on that page). This action is very specific in the sense that it downloads a archive of a public or private repo.

Choose a reason for hiding this comment

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

ah ok, I missed that this was for downloading a repo archive. I assumed it was for downloading other artifacts from a release. Should the action name indicate that it's for that, specifically, then? Is there a reason to download the release archive of a repo instead of using git operations to pull a repo at a specific tag?

Copy link
Author

Choose a reason for hiding this comment

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

The repo being pulled is a private repo

iam-role:
description: The iam role to assume
required: true
bin-name:

Choose a reason for hiding this comment

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

why are the path to and name of terragrunt parameterized? is it unsafe to assume terragrunt will be configured on PATH before the action is called?

Copy link
Author

Choose a reason for hiding this comment

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

I parameterized them to avoid assumptions that could not be overwritten. The default value for the terragrunt location is /usr/local/bin (and default name of binary being terragrunt). When used in conjuction with the terragrunt-setup action, the binary will be in the expected location so as not to require overwriting the defaults. However if terragrunt was downloaded or installed by another means, then the terragrunt location can be explicitly specified. Looking at it again, it does seem overly complicated to parameterize both values, and I could consolidate them into a single input, for example "terragrunt-bin-path".

env:
TERRAGRUNT_IAM_ROLE: ${{ inputs.iam-role }}
run: |
${{ inputs.terragrunt-bin-path }} run-all ${{ inputs.run-all-action }} --terragrunt-non-interactive --terragrunt-working-dir ${{ inputs.folder }} ${{ inputs.additional-options-args }}

Choose a reason for hiding this comment

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

If this action is wrapping a single run step, does it still make sense to have it as a separate action? Is it likely that this action will do other things before the run-all?

Copy link
Author

Choose a reason for hiding this comment

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

Do you meant there would be some additional parameters between ${{ inputs.terragrunt-bin-path }} and "run-all"? Or that there might be an additional step before "terragrunt run-all"? If it's the latter, my thinking with this action is only used to run the terragrunt plan command, and abstract away the nuances for doing that

Copy link
Author

Choose a reason for hiding this comment

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

The more I think about it, terragrunt run-all commands can get too nuanced to handle with an overly simple action such as this, so I think I'm going to remove it from this pr.

@andrewhaller
Copy link
Author

@steve-liatrio I made some updates. I haven't finished the README files. How do you feel about merging this into master?

@steve-liatrio
Copy link

Hey @andrewhaller, sorry I forgot to keep track of this PR. If there's somebody who's more familiar with this change it might be a good idea to get them to review it, as I still don't feel like I have a lot of context for the change.

I would recommend READMEs, though. It would help for those without context 🙂
Maybe we could huddle on this at some point if you have time?

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.

2 participants