Is there a way to access the current tag that has been pushed in a Github Action? In CircleCI you can access this value with the $CIRCLE_TAG
variable.
My Workflow yaml is being triggered by a tag like so:
on: push: tags: - 'v*.*.*'
And I want to use that version number as a file path later on in the workflow.
github action sets the git tag as an env var. run install & build. use chrislennon/action-aws-cli action to install aws cli using secrets for keys. run command to sync the build to a new S3 bucket using the tag env var as the dir name.
Introduction. In this post we will be creating a new Github Action to automatically tag commits when a pull request is merged. Git tags are specific points in a repository's history marked as being important, typically used to identify release versions.
Anyone can view GitHub Actions usage for their own personal account. In the upper-right corner of any page, click your profile photo, then click Settings. In the "Access" section of the sidebar, click Billing and plans. Under "GitHub Actions", view details of your minutes used.
As far as I know there is no tag variable. However, it can be extracted from GITHUB_REF
which contains the checked out ref, e.g. refs/tags/v1.2.3
Try this workflow. It creates a new environment variable with the extracted version that you can use in later steps.
on: push: tags: - 'v*.*.*' jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Test run: | echo $RELEASE_VERSION echo ${{ env.RELEASE_VERSION }}
Alternatively, use set-output
:
on: push: tags: - 'v*.*.*' jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set output id: vars run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} - name: Check output env: RELEASE_VERSION: ${{ steps.vars.outputs.tag }} run: | echo $RELEASE_VERSION echo ${{ steps.vars.outputs.tag }}
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