ikreb
ikreb

Reputation: 2785

Github Actions: How to create multiline env variable for serveral jobs

I want to add serveral lines to a code file. And this in various jobs. So I created one job which create a text file and upload it.

create_file:
  runs-on: ubuntu-latest
  steps:      
    - shell: bash
      run: |
        cat << EOF > data.txt
        A = "..."
        B = "..."
        C = "..."
        ...
        EOF
    - name: Create data file
      uses: actions/upload-artifact@1
      with:
        name: configuration
        path: data.txt

At the next job I upload the file and want to append this lines to a code file.

test_file:
  runs-on: ubuntu-latest
  needs: [create_file]
  steps:
  - name: Download file     
    uses: actions/download-artifact@v1
    with:
      name: configuration
      path: configuration/data.txt
  - shell: bash
     run: |
       cat configuration/data.txt >> main.py
       python main.py

I have the problem that the second job is too fast and searches after the data.txt file before it is already uploaded and how I could handle the to append content. The command echo "..." >> main.py for each line would be very annoying.

Update: Now I get for the job data.txt following error messages:

 Download action repository 'actions/upload-artifact@1'
 ##[warning]Failed to download action 'https://api.github.com/repos/actions/upload-artifact/tarball/1'. Error Response status code does not indicate success: 404 (Not Found).
 ...
 ##[error]Response status code does not indicate success: 404 (Not Found).

Upvotes: 2

Views: 5405

Answers (1)

ikreb
ikreb

Reputation: 2785

The error was very stupid. The line actions/upload-artifact@1 should be actions/upload-artifact@v1.

Upvotes: 1

Related Questions