Pass data from original workflow that triggered current workflow

I have two workflows set up in the same repo - One that creates a docker image and pushes to a container registry when code is pushed to develop branch (similar logic but for different branches - has more than one workflow of such nature). The second workflow (multiple copies with different intentions) gets triggered on successful completion of the first workflow and takes that image and deploys to either an Azure Container or Kubernetes namespace (as an example).

This all works fine workflow wise - but there are multiple builds that get triggered for different reasons and on different branches - the strategy kind of fails to achieve its purpose because the second workflow tends to use the container tag latest for all cases. So there is kind of a race condition situation on which (first) workflow creates the last latest image tag and which one gets picked up in the second workflow

Here is my code in the second workflow that gets trigged:

    workflows: ["Original Workflow Name"]
      - develop
      - completed

In the first workflow, I have made changes so it would generate a unique tag each time it runs and push that specific image tag to the registry.

I need a way to pass this unique tag value or make it available to the second workflow when it starts so it can read that tag value and fetch that specific image and deploy to where it was indented to.

I tried Environment variables - but either I am using it wrong or it does not work that way but I do not get same values in the second workflow run seems like they are using different build agent instances or something, is there a formal way to achieve this?

Does not have to be just tag values - but in general, if there is a way to make a generic key-value store available to the trigged second workflow that would be great, thanks in advance.

1 Like

Hey. I had similar task and implemented it via repository dispatch. So, source repo triggers another workflow with simple curl

      - name: Directory update request
        run: |
          [ -z "${{ secrets.ISSUE_PAT }}" ] && echo "Skipping, no ISSUE_PAT" && exit 0
          curl --request POST \
          --url<company>/<registry>/dispatches \
          --header 'authorization: Bearer ${{ secrets.ISSUE_PAT }}' \
          --header 'content-type: application/json' \
          --data '{
            "event_type": "repo_updated",
            "client_payload": {
                "repo": "${{ github.repository }}"

And receiving repo has several triggers, one of which is

    types: [repo_updated]
    runs-on: ubuntu-latest
      - uses: actions/checkout@v2
      - name: Process update
        run: ./ "${{ github.event.client_payload.repo }}"

I don’t think there’s ability to pass data with workflow_run trigger. This is a workaround, and it even works between repos. ISSUE_PAT is a personal access token.

Is this still open issue that passing values between workflows is a challenge