Is it possible to pass in a dynamic version to an action? Below [dynamic version]
is what I would want populated from either an input
or env
or some other way.
- name: Run action with dynamic version
uses: org1/repo1/.github/actions/my-action1@[dynamic version]
- name: Run action with dynamic version
uses: org1/repo1/.github/actions/my-action2@[dynamic version]
For more information, we have several internal actions where all the versions are the same (coming from same repo). We move the versions at the same time and thought it would be convenient to have some way to specify this once.
CodePudding user response:
You probably want to use semantic versioning for your actions and create a major version for consumers to use.
Semantic versioning essentially allows all users of your actions to reference only the major version and profit from patches and new features as they are released. At the same time, your users need to manually update the reference on breaking changes as that would change the major tag.
In practice, this means:
- When you create a new version of an action, you create a new release on GitHub specifying a full version, e.g.
v1.0.0
- You then create a tag called
v1
that points to the same commit - Later on, when you fix something, you create a new version
v1.0.1
- Now you also need to update the tag
v1
to point to the new commit (typically delete it & recreate)
This is a clunky process, but this is what most authors do.
If this for some reason doesn't satisfy your requirements, you could also think about always using the @main
reference. This is generally not advised for public actions as changes might break your workflows, but in a controlled internal environment this might be fine.
Lastly, note that dependabot can create PRs in your repositories when there's a new version of actions you're using. I have detailed more on this in a previous answer: https://stackoverflow.com/a/70196496/1080523