Skip to content

Setting environment variables in on_retry_command does not propagate to next attempt #153

@nh13

Description

@nh13

I would have expected MY_ENV_VAR to be non-empty on the second attempt after it is exported.

name: tests

on:
  push:
    branches:
      - "**"
    tags:
      - "!**"
  workflow_call:

jobs:
  testing:
    runs-on: ubuntu-24.04
    steps:
    - uses: nick-fields/retry@v3
      with:
        shell: bash
        max_attempts: 2
        retry_on: error
        polling_interval_seconds: 5
        timeout_minutes: 90
        command: |
          set -x
          echo "MY_ENV_VAR='${MY_ENV_VAR}'"
          if [ "${MY_ENV_VAR}" == "" ]; then
            exit 1
          else
            exit 0
          fi
        on_retry_command: |
          echo "MY_ENV_VAR=true" >> $GITHUB_ENV
          export "MY_ENV_VAR=true"

See: https://github.com/nh13/nick-fields-retry-env-var/actions/runs/13893887269/job/38870357956

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions