I’m working on a GitHub Actions workflow where I need to start multiple EC2 instances and aggregate their outputs. However, I’m encountering an issue where the output is an empty object. Here is my current workflow configuration:
`
name: Start Runner
on:
workflow_call:
inputs:
jobs:
type: string
description: “The jobs to launch”
required: true
outputs:
runners:
description: “The runners to launch in format / lint / tests runners”
value: ${{ jobs.aggregate-runners.outputs.runners }}
instances:
description: “The EC2 instance IDs”
value: ${{ jobs.aggregate-runners.outputs.instances }}
jobs:
start-executioner:
name: Start job self-hosted EC2 runner
permissions:
id-token: write
contents: write
runs-on: ubuntu-latest
strategy:
matrix:
job: ${{ fromJSON(inputs.jobs) }}
steps:
– name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::x:role/github-action-role
aws-region: eu-west-3
- name: Start EC2 executioner
id: start-ec2-executioner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.GH_API_ACCESS_TOKEN }}
ec2-image-id: ami-id
ec2-instance-type: t3.nano
subnet-id: subnet-id
security-group-id: sg-id
- name: Set outputs
id: set-outputs
run: |
echo "${{ matrix.job }}-runner=${{ steps.start-ec2-executioner.outputs.label }}" >> "$GITHUB_OUTPUT"
echo "${{ matrix.job }}-instance=${{ steps.start-ec2-executioner.outputs.ec2-instance-id }}" >> "$GITHUB_OUTPUT"
print-executioners:
name: Print executioners
runs-on: ubuntu-latest
needs: start-executioner
steps:
– name: Print executioners
run: |
echo “Runners: ${{ needs.start-executioner.outputs.runners }}”
echo “Instances: ${{ needs.start-executioner.outputs.instances }}”
`
The problem I’m facing is that the outputs runners and instances are empty when accessed in the print-executioners job. I suspect there might be an issue with how I’m setting or accessing the outputs, but I can’t figure out what it is.
Any help or suggestions on how to resolve this issue would be greatly appreciated!
Thank you in advance!
i’m trying to set different outputs for each ec2 instances, but i figure out thats not working…
I want to be able to get each outputs of start-executioner iteration, to make the workflow outputs all runners, and instances
kfachas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.