Is there a way to get the project folder name only on a Github action?
In addition to @Samira response, you could also use ${GITHUB_REPOSITORY#*/}
to get the repository name, since it will cut all before the /
prefix.
For e.g., at my workflow I use:
- run: echo ::set-env name=TF_VAR_instance_label::${GITHUB_REPOSITORY#*/}-${GITHUB_SHA:0:7}
github
context also contains event data, from where you can easily read some more detailed info. In this case, ${{ github.event.repository.name }}
will give you only repo-name
part.
It might be a good idea to create testing workflow/job to print all context data until you're familiar with them, see Example printing context information to the log file.
As for replacing text, you can always dedicate one of first steps to prepare everything you need later with either ::set-env or ::set-output. You just need to print name/value in specific format, so you can use any shell you're familiar with to manipulate text while doing that:
# All steps after this one will have env variable `GHA_BRANCH` passed to them.
- run: echo ::set-env name=GHA_BRANCH::$(echo $GITHUB_REF | awk -F / '{print $3}')
shell: bash