Reputation: 2275
I've got this step:
- name: getSumac
uses: actions/checkout@v2
with:
repository: yma/sumac
ref: ${{ github.ref }}
That works when the action is triggered by pushing a tag. But when a PR is created or updated, github.ref
is something like refs/pull/99/merge
and the getSumac
step fails.
On the command-line, I would run something like $( git describe --tags | grep -Eo '^v[.0-9]+' )
to get the most recent tag. Is there a way to do that in a github action step?
Upvotes: 3
Views: 349
Reputation: 2275
Turns out in this case I could set a VERSION
env var, so I could do something like this:
steps:
- name: Override the VERSION env var
run: |
VERSION=${VERSION:-$(git describe --tags | sed 's/^v//')}
if [ -n "$VERSION" ] ; then
echo "VERSION=$VERSION" >> $GITHUB_ENV
fi
And the actions I'm using just use $GITHUB_ENV
(I never reference it explicitly in the other steps).
Upvotes: 1