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

Set default inputs to simplify action code #8

Open
domharrington opened this issue May 4, 2023 · 1 comment
Open

Set default inputs to simplify action code #8

domharrington opened this issue May 4, 2023 · 1 comment

Comments

@domharrington
Copy link
Member

No description provided.

@kanadgupta kanadgupta changed the title Set default glob to simplify action code Set default inputs to simplify action code May 4, 2023
@kanadgupta
Copy link
Member

Background

Currently, the default Action code sample looks something like this:

- name: Sync to ReadMe Micro
  uses: readmeio/[email protected]
  with:
    micro: '**/*.{json,yaml,yml}' --key=${{ secrets.README_MICRO_KEY }}

Rather than requiring users to pass in a blob via an Actions input (i.e., **/*.{json,yaml,yml}, the default behavior should be to:

  • Find every OpenAPI/Swagger file in their repo without that parameter
  • Allow the user to optionally pass in a glob that confines what directories the Action searches, if needed

Additionally, it'd be nice if the code also accepted README_MICRO_KEY as an environmental variable, which should eliminate the need for the --key CLI argument in Bitbucket Pipelines and perhaps other environments.

What we do in rdme

We automatically search for JSON and YAML files in non-git-ignored directories here:

https://github.com/readmeio/rdme/blob/9fc7a0ff9bac4cb539095cfa2f5eeec6cba48f16/src/lib/prepareOas.ts#L86-L91

And then using oas-normalize, we iterate through every discovered JSON/YAML file and filter for files that match the properties of a OpenAPI, Swagger, or Postman definition:

https://github.com/readmeio/rdme/blob/9fc7a0ff9bac4cb539095cfa2f5eeec6cba48f16/src/lib/prepareOas.ts#L95-L115

In terms of how we process the API key, we allow the user to pass it in as a CLI arg, environmental variable, or via a configuration file (in that order of precedence). We document that behavior here:

https://github.com/readmeio/rdme/blob/v8.6.3/README.md#authentication

Here's where we handle that precedence in rdme:

https://github.com/readmeio/rdme/blob/9fc7a0ff9bac4cb539095cfa2f5eeec6cba48f16/src/index.ts#L147-L149

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

No branches or pull requests

2 participants