I can get repoowner/repo-name
with ${{ github.repository }}
but I like to get just the repo-name
.
While I am at it.
GitLab has a straight forward variable for this.
How do I get reference access env variables from the .yaml
not inside scripts? Does ${{ $ENV_VAR }}
work? Probably not.
Is there a way to remove or replace the slashes directly in the yaml?
build: needs: test name: Build release Zip runs-on: ubuntu-latest env: DEPLOY_REF: ${{ github.sha }} DEPLOY_REF_SHORT: ${{ github.sha }} DEPLOY_ZIPFILE: ${{ github.workspace }}/build/zip/${{ github.repository }}-${{ github.sha }}.zip steps:
GitHub Actions uses YAML syntax to define the workflow. Each workflow is stored as a separate YAML file in your code repository, in a directory named . github/workflows .
ID is used as a reference, from other jobs or steps (for example, in jobs. <job_id>. needs ). Name is used for display purposes on GitHub.
github.head_ref. string. The head_ref or source branch of the pull request in a workflow run. This property is only available when the event that triggers a workflow run is either pull_request or pull_request_target . github.job.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With