0

I am looking to create multiple self hosted github runner dynamically for each database on same machine. I am able to create manually but looking to automate this process and wanted to run different runner on different database.

Is there any way to create multiple self hosted github runner dynamically for each database.

name: Deploy AMR Dev
on:
  push:
    branches:
      - dev
      
env:
    APPLICATION_NAME: abc
    AWS_REGION: us-west-2
    ROLE_SESSION_NAME: CI-amr-dev
  
permissions:
  id-token: write
  contents: read    # This is required for actions/checkout@v2

jobs:

  setup-runner-amr:
    runs-on: ubuntu-latest
    strategy:
      matrix:
       schema-runner : [db1,db2]
    env:
      create-github-runner : ${{matrix.schema-runner}}
    permissions:
      id-token: write
      contents: read
    outputs:
      gitrunner_label: ${{ steps.create-github-runner.outputs.runner-label }}
      gitrunner_label_1: ${{ steps.create-github-runner-1.outputs.runner-label }}
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@master
        with:
          role-to-assume: "role to assume"
          aws-region: "aws region"
          
      - name: Create self hosted runner action step
        uses: abc/action-self-hosted-runner-ecs@v0.0.4
        id: create-github-runner
        with:
          ecs-cluster-name: ${{ secrets.CLUSTER_NAME_AMR }}
          task-def: ${{ secrets.TASK_DEF_AMR }}
          subnets: ${{ secrets.SUBNET_AMR }}
          security-groups: ${{ secrets.SG_AMR }}
      
      - name: Create another self hosted runner action step
        uses: abc/action-self-hosted-runner-ecs@v0.0.4
        id: create-github-runner-1
        with:
          ecs-cluster-name: ${{ secrets.CLUSTER_NAME_AMR }}
          task-def: ${{ secrets.TASK_DEF_AMR }}
          subnets: ${{ secrets.SUBNET_AMR }}
          security-groups: ${{ secrets.SG_AMR }}

  deploy
    needs: [setup]
    runs-on: [self-hosted, "${{ needs.setup.outputs.gitrunner_label }}"]
    steps:
    - run: |
        echo "${{needs.setup.outputs.gitrunner_label}}"

2 runner has created for each database but in 2nd job deploy there i can only task and which also not picking up by self hosted runner. help me to improve the code.

Manish
  • 71
  • 7

0 Answers0