diff --git a/.github/actions/is_callee/action.yml b/.github/actions/is_callee/action.yml new file mode 100644 index 000000000..3c4c4eec3 --- /dev/null +++ b/.github/actions/is_callee/action.yml @@ -0,0 +1,21 @@ +name: Check if being used as reusable workflow +description: Determines if running as part of a reusable workflow by checking if the specified current workflow file is the same as the caller +inputs: + current_workflow_file: + required: true + description: The name of the workflow file this action is called from +outputs: + is_callee: + value: ${{ steps.workflows_match.outputs.is_callee }} + description: Returns 'true' (string) if called as a reusable workflow +runs: + using: "composite" + steps: + - id: workflows_match + run: | + if echo ${{ github.workflow_ref }} | grep ${{ inputs.current_workflow_file }}; then + echo "is_callee='false'" >> "$GITHUB_OUTPUT" + else + echo "is_callee='true'" >> "$GITHUB_OUTPUT" + fi + shell: bash diff --git a/.github/workflows/fatimage.yml b/.github/workflows/fatimage.yml index f63e55701..1b582aee1 100644 --- a/.github/workflows/fatimage.yml +++ b/.github/workflows/fatimage.yml @@ -54,9 +54,14 @@ jobs: openhpc-RL9-image: "${{ steps.manifest.outputs.openhpc-RL9-image }}" steps: + - uses: stackhpc/ansible-slurm-appliance/.github/actions/is_callee@feat/auto-bump-timestamps # todo: change to main once merges + id: callee_check + with: + current_workflow_file: fatimage.yml + - uses: actions/checkout@v3 with: - ref: ${{ github.event_name != 'workflow_call' && github.ref || inputs.target_branch }} + ref: ${{ steps.callee_check.outputs.is_callee && inputs.target_branch || github.ref }} - name: Record settings for CI cloud run: | diff --git a/.github/workflows/stackhpc.yml b/.github/workflows/stackhpc.yml index b32ef4a2d..6972c108a 100644 --- a/.github/workflows/stackhpc.yml +++ b/.github/workflows/stackhpc.yml @@ -49,9 +49,14 @@ jobs: CI_CLOUD: ${{ vars.CI_CLOUD }} # default from repo settings TF_VAR_os_version: ${{ matrix.os_version }} steps: + - uses: stackhpc/ansible-slurm-appliance/.github/actions/is_callee@feat/auto-bump-timestamps # todo: change to main once merges + id: callee_check + with: + current_workflow_file: stackhpc.yml + - uses: actions/checkout@v3 with: - ref: ${{ github.event_name != 'workflow_call' && github.ref || inputs.target_branch }} + ref: ${{ steps.callee_check.outputs.is_callee && inputs.target_branch || github.ref }} - name: Override CI_CLOUD if PR label is present if: ${{ github.event_name == 'pull_request' }}