Upload-artifact: support env in name

Created on 15 Feb 2020  路  5Comments  路  Source: actions/upload-artifact

first of all thank you for this action ! it is very usefull !
secondly I have a feature request,

actions/upload-artifact

    - uses: actions/upload-artifact@v1
      with:
        name: all_reports
        path: all_reports

I would like to be able to change the name based on the GITHUB_REF env variables

I tried this but it wont work:

    - uses: actions/upload-artifact@v1
      with:
        name: all_reports_${GITHUB_REF}
        path: all_reports

I also have tried

       name: all_reports_${{ GITHUB_REF }}

no luck

Most helpful comment

@medyagh @ipmb I couldn't make it work neither with ${{ env.GITHUB_RUN_NUMBER }}.

However it worked with ${{ github.run_number }} 馃憣馃徑

All 5 comments

Hi, just being helpful:

Instead of name: all_reports_${{ GITHUB_REF }} try name: all_reports_${{ env.GITHUB_REF }}

The default "context" of template expressions is a collection of root contexts, so to use environment variables you need to use env context: https://help.github.com/en/actions/reference/contexts-and-expression-syntax-for-github-actions#env-context

I get

ERRORED 10:45:23Z

  • Your workflow file was invalid: The pipeline is not valid. .github/workflows/testenv.yml (Line: 19, Col: 15): Unexpected symbol: '$GITHUB_RUN_NUMBER'. Located at position 5 within expression: env.$GITHUB_RUN_NUMBER

Here is my workflow:
- name: Upload artifact
uses: actions/[email protected]
with:
# Artifact name
name: docker_${{ env.$GITHUB_RUN_NUMBER }}
# Directory containing files to upload
path: .

Is there a workaround for this?

@Allendorf243 I think you've got an extra $ in there. You probably want ${{ env.GITHUB_RUN_NUMBER }}

@medyagh @ipmb I couldn't make it work neither with ${{ env.GITHUB_RUN_NUMBER }}.

However it worked with ${{ github.run_number }} 馃憣馃徑

You can use env variables as input, in your example though you should be using the github context to get the REF.

https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context

Example

jobs:
  example:
    runs-on: [ubuntu-latest]
    env:
      input: environment_variable
    steps:

    # use variable from env context
    - uses: actions/upload-artifact@v1
      with:
        name: all_reports_${env.input}
        path: all_reports

    # use variable from github context
    - uses: actions/upload-artifact@v1
      with:
        name: all_reports_${github.ref}
        path: all_reports
Was this page helpful?
0 / 5 - 0 ratings

Related issues

craig-dae picture craig-dae  路  6Comments

lacasseio picture lacasseio  路  3Comments

ccjernigan picture ccjernigan  路  10Comments

luna-kx picture luna-kx  路  5Comments

emilianbold picture emilianbold  路  3Comments