I have the following GitHub Actions, I want to pass lastNotificationMessage
from deploy job to the next job (for the details please check the screenshots):
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?
Below is the screenshot:
deploy job:
notification job:
Other method suggested by @Shayki which I tried but not success:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy
id: deployToCloud
timeout-minutes: 1
run: |
echo "deploymentId=$DEPLOYMENT_ID" >> $GITHUB_OUTPUT
- name: Get last notification
if: always()
id: lastNotification
timeout-minutes: 1
run: |
LAST_NOTIFICATION=$(app get-last-notification)
echo "$LAST_NOTIFICATION"
echo "lastNotificationMessage=$LAST_NOTIFICATION" >> $GITHUB_OUTPUT
outputs:
deploymentId: ${{ steps.deployToCloud.outputs.deploymentId }}
lastNotificationMessage: ${{ steps.lastNotification.outputs.lastNotificationMessage }}
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:
DEPLOYMENT_ID: ${{ needs.deploy.outputs.deploymentId }}
LAST_NOTIFICATION_MESSAGE: ${{ needs.deploy.outputs.lastNotificationMessage }}
deploy step:
next step:
Get last notification
set to always run regardless the result of other steps.$GITHUB_OUTPUT
?$GITHUB_OUTPUT
. I use the same method forDEPLOYMENT_ID
andLAST_NOTIFICATION_MESSAGE
but only the first variable have value on the next step.