1

I'm trying to set the output from a command to an other command in a github action in the following way:

- name: 'Checkout source code'
  uses: actions/checkout@v2
  with:
    fetch-depth: 0
 - name: 'Create delta packages for new, modified or deleted metadata'
   run: | 
     mkdir changed-sources
     echo "DIFF=$(git rev-parse --short origin/dev)" >> $GITHUB_ENV
     echo "${{ env.DIFF }}"
     sfdx sgd:source:delta --to "HEAD" --from ${{ env.DIFF }} --output changed-sources/ --generate-delta --source force-app/

But for some reason it's not working, I receive the following output:

steps:
  mkdir changed-sources
  echo "DIFF=$(git rev-parse --short origin/dev)" >> $GITHUB_ENV
  echo ""
  sfdx sgd:source:delta --to "HEAD" --from  --output changed-sources/ --generate-delta --source force-app/

What I'm I missing, any help would be highly appreciated!

1 Answer 1

2

According to the official GitHub documentation:

If you generate a value in one step of a job, you can use the value in subsequent steps of the same job by assigning the value to an existing or new environment variable and then writing this to the GITHUB_ENV environment file.

In your example, you are using the env variable in the same step.

You should therefore access the env variable in another step instead of in the same one.

Example:

- name: 'Checkout source code'
  uses: actions/checkout@v2
  with:
    fetch-depth: 0
 - name: 'Create delta packages for new, modified or deleted metadata'
   run: | 
     mkdir changed-sources
     echo "DIFF=$(git rev-parse --short origin/dev)" >> $GITHUB_ENV
 - name: NEW STEP
    run: |
     echo "${{ env.DIFF }}"
     sfdx sgd:source:delta --to "HEAD" --from ${{ env.DIFF }} --output changed-sources/ --generate-delta --source force-app/
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, this was exactly what the issue was! Thank you for taking your time to assist and provide an answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.