Skip to content

Commit

Permalink
Implemented condition at entry point of workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
grasci-arm authored Nov 14, 2022
1 parent c10a75f commit 761f0e7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/shared_matrix_prep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
type: string
run_if:
description: 'True to get configuration matrix'
default: false
required: true
default: true
required: false
type: boolean
outputs:
matrix:
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/shared_setup_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: setup_env

on:
workflow_call:
inputs:
run_if:
description: 'True if workflow needs to run'
default: false
required: true
type: boolean
outputs:
nightly:
description: 'True if workflow triggered by nightly, else False'
Expand All @@ -13,13 +19,18 @@ on:
jobs:
config:
runs-on: ubuntu-22.04
if: ${{ (github.event.schedule && github.event.repository.private) == false }}
if: ${{ inputs.run_if }}
outputs:
nightly: ${{ steps.config.outputs.nightly }}
retention_days: ${{ steps.config.outputs.retention_days }}
steps:
- name: check condition status
run : |
echo ${{ github.event.schedule }}
echo ${{ github.event.repository.private }}
echo ${{ (github.event.schedule && github.event.repository.private) == false }}
- name: Check Nightly/Scheduled
id: config
run: |
echo "nightly=$(echo '${{ (github.event.schedule && (!github.event.repository.private)) && 'true' || 'false' }}')" >> $GITHUB_OUTPUT
echo "retention_days=$(echo '${{ (github.event.schedule && (!github.event.repository.private)) && '7' || '1' }}')" >> $GITHUB_OUTPUT
echo "nightly=$(echo '${{ ((github.event.schedule != '') && (!github.event.repository.private)) && 'true' || 'false' }}')" >> $GITHUB_OUTPUT
echo "retention_days=$(echo '${{ ((github.event.schedule != '') && (!github.event.repository.private)) && '7' || '1' }}')" >> $GITHUB_OUTPUT

0 comments on commit 761f0e7

Please sign in to comment.