Does anyone know what this does ?
uses: ./
I see it used in quite a few places but cannot seem to find any reference for it.
The uses keyword of github actions is used to specify the action that should be executed as part of a workflow. The ./ value tells GitHub to use the action defined in the current repository, rather than referencing a pre-built action.
It's also possible to specify the path to the action within the repository, rather than using ./. For example:
steps:
- uses: ./path
with:
parameter1: value1
parameter2: value2
This would execute the action located at ./path within the repository.
Related
I am currently trying to use the CLA-Assistant-Lite github action.
The workflow appears to have an issue related to the use of Node.js 12.
Someone has opened a pull request to address the issue that I would like to use.
I can not figure out how to modify my .yml to use the code from the pull request vs. the current release.
The .yml currently has the line :
uses: contributor-assistant/github-action#v2.2.1
How can I modify it to use the pull request code instead of the v2.2.1 tag?
You can change the uses line to reference the SHA from the commit you want to use instead of a version. It also accepts a branch. Simply change the part after the # symbol.
In your case I think you want:
uses: contributor-assistant/github-action#4b65b2db8e3217d589ae15875814a011c1a9b69d
See the actions docs here about syntax for uses
I know about organization-wide secrets for GitHub Actions, but I'm looking for a way to define organization-wide non-secret variables, such as default environment variables or something similar.
Sometimes you simply don't want all your shared config to be secret. An example is for AWS credentials, where it may be beneficial to see the AWS_ACCESS_KEY_ID in plain text, but keep the AWS_SECRET_ACCESS_KEY as a secret.
It seems silly to have to put the same AWS_ACCESS_KEY_ID variable as an env variable in every single repo, while the secret half of that pair works perfectly to configure once for the entire organization... Is there such a way?
Perhaps a workaround could be to create a reused workflow action such as set-env that sets the shared environment variables and then include that in each and every job such as uses: my-org/github-actions/.github/workflows/set-env.yml#main, but it's not the cleanest solution I think.
Too bad there's simply not an option next to GitHub action secrets to allow them to be ... well, not so secret.
In Github Actions composite actions, you must specify the branch where the composite action is located, e.g.,
- uses: /username/repo-name/.github/composite-actions#main
Is there a way to specify the current branch instead rather than hardcode #main?
After checking further, it seems using the relative path works. For example:
- uses: ./.github/composite-actions
Is there any way that a step in a workflow job can specify sub-steps to pass to a custom action?
steps:
- uses: ...
with:
steps:
- ...
- ...
- ...
For example, a uses: actions/cache#v2 will attempt to download a snapshot immediately (in the current step), and also inserts a post step to upload a fresh snapshot after all other steps in the parent job. This works well for build processes that (through multiple stages) intelligently recognise which objects need to be recreated and which do not. But it is not suited for workflows that need to set up a clean environment (or generate test data) that may then be manipulated by the tests. I'd like to make a different cache action, that is explicitly passed instructions for how to regenerate the cache from scratch, and which uploads the state before returning to the following step of the parent action.
Is there any way this could be achieved? (Composite actions? Advanced yaml syntax? Template expressions? Low-level actions toolkits/features? Implementing an interpreter to re-parse the input parameter?)
I'm using the cache GitHub action and I'm generating a cache key with the built-in hashFiles function:
key: ${{ runner.os }}-${{ hashFiles('./packages/protocol/{,!(node_modules)}**/*') }}-coverage-lcov
The command above does not work, however. What I see in the GitHub Actions logs is this:
Cache saved with key: Linux--coverage-lcov
There is no hash generated, presumably because the glob is incorrect. How can I correctly ignore the node_modules folder in the path provided to the hashFiles function?
Your paths need to be in separate parameters, as shown in the example given on the hashFiles docs page you linked:
hashFiles('**/package-lock.json', '**/Gemfile.lock')
Aditionally you seem to be missing Some * after the end of the { and maybe before the node_modules depending on your directory setup.