Skip to content

Set env variables for scheduled workflow based on cron expression #25928

Discussion options

You must be logged in to vote

Hi @andrzej-kodify,

Glad to see you in Github Community Forum!

You cannot define top level env in the event, it’s not supported. As an alternative, based on the different schedule cron settting, you can use ‘set-env’ to set/update env value for the job.

Code sample as below:

on:
  schedule:
    - cron:  '*/6 * * * *'   # define cron setting
    - cron:  '*/7 * * * *'
jobs:
  jobenv:
    runs-on: ubuntu-latest
    steps:
      - name: setenv
        if: github.event.schedule=='*/6 * * * *'         # set-env value
        run: |
          echo "::set-env name=cronenv::midnight_run"
      - name: setenv2
        if: github.event.schedule=='*/7 * * * *'   # set env value
        run: |
      …

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@gokultw
Comment options

@tzachshabtay
Comment options

Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants