In the beginning of a (re-usable) workflow
env:
STAGING_GCR_PROJECT: my-project-id
and when using it
slack_staging_success:
needs: build_staging
runs-on: ubuntu-latest
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }}
env:
STAGING_IMAGE: "gcr.io/$STAGING_GCR_PROJECT/${{ inputs.image_name }}:${{ inputs.image_tag }}"
steps:
- name: slack success for staging
uses: rtCamp/action-slack-notify@v2
env:
SLACK_ICON: $SLACK_ICON_SUCCESS
SLACK_COLOR: green
SLACK_MESSAGE: "STAGING image ${{ env.STAGING_IMAGE }} was built / pushed with SUCCESS"
In Slack the message interpolates as
STAGING image gcr.io/$STAGING_GCR_PROJECT/echo-server:1.0.2 failed to be built
Why isn’t $STAGING_GCR_PROJECT
interpolated correctly?
2
Answers
In order to use workflow environment variables, use the prefix
env.
and enclose it in${{ }}
just like you did with the inputs:It is not supported at the moment, to have env variable inside env.
The docs on env mentions it: