I have the following GitHub Actions, I want to pass lastNotificationMessage
from deploy job to the next job:
<code>jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Get last notification
if: always()
id: notification
timeout-minutes: 1
run: |
LAST_NOTIFICATION=$(app get-last-notification)
echo "$LAST_NOTIFICATION"
echo "CUSTOM_LAST_NOTIFICATION=$LAST_NOTIFICATION" >> $GITHUB_ENV
outputs:
lastNotificationMessage: ${{ env.CUSTOM_LAST_NOTIFICATION }}
# otherVariable: other value
# otherVariable: other value
# otherVariable: other value
# otherVariable: other value
# otherVariable: other value
# otherVariable: other value
notification:
runs-on: ubuntu-latest
needs: deploy
if: always()
steps:
- name: Notification
timeout-minutes: 1
run: |
app send-notification
--last-message "$LAST_NOTIFICATION_MESSAGE"
env:
LAST_NOTIFICATION_MESSAGE: ${{ needs.deploy.outputs.lastNotificationMessage }}
</code>
<code>jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Get last notification
if: always()
id: notification
timeout-minutes: 1
run: |
LAST_NOTIFICATION=$(app get-last-notification)
echo "$LAST_NOTIFICATION"
echo "CUSTOM_LAST_NOTIFICATION=$LAST_NOTIFICATION" >> $GITHUB_ENV
outputs:
lastNotificationMessage: ${{ env.CUSTOM_LAST_NOTIFICATION }}
# otherVariable: other value
# otherVariable: other value
# otherVariable: other value
# otherVariable: other value
# otherVariable: other value
# otherVariable: other value
notification:
runs-on: ubuntu-latest
needs: deploy
if: always()
steps:
- name: Notification
timeout-minutes: 1
run: |
app send-notification
--last-message "$LAST_NOTIFICATION_MESSAGE"
env:
LAST_NOTIFICATION_MESSAGE: ${{ needs.deploy.outputs.lastNotificationMessage }}
</code>
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Get last notification
if: always()
id: notification
timeout-minutes: 1
run: |
LAST_NOTIFICATION=$(app get-last-notification)
echo "$LAST_NOTIFICATION"
echo "CUSTOM_LAST_NOTIFICATION=$LAST_NOTIFICATION" >> $GITHUB_ENV
outputs:
lastNotificationMessage: ${{ env.CUSTOM_LAST_NOTIFICATION }}
# otherVariable: other value
# otherVariable: other value
# otherVariable: other value
# otherVariable: other value
# otherVariable: other value
# otherVariable: other value
notification:
runs-on: ubuntu-latest
needs: deploy
if: always()
steps:
- name: Notification
timeout-minutes: 1
run: |
app send-notification
--last-message "$LAST_NOTIFICATION_MESSAGE"
env:
LAST_NOTIFICATION_MESSAGE: ${{ needs.deploy.outputs.lastNotificationMessage }}
When I echo it on the first job, it already has value (it’s in base64url-encoded format to make sure it doesn’t have any dangerous character).
But on the next job, When I check it in the job output, it’s alway empty. I can see that the other variables have correct value also.
What is the issue here and how can I fix it?