Skip to content

Jason-Clark-FG/azure-github-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

On-demand self-hosted Azure Virtual Machines runner for GitHub Actions

Start your Azure Virtual Machines self-hosted runner right before you need it. Run the job on it. Finally, stop it when you finish. And all this automatically as a part of your GitHub Actions workflow.

Exemple

A workflow do-the-job.yml looks like this:

name: do-the-job
on: push
jobs:
  start-runner:
    uses: Jason-Clark-FG/azure-github-runner/.github/workflows/create.yml@v1
      with:
        VM_SIZE: Standard_B1s
        LOCATION: northeurope
      secrets:
        ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
        ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
        ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
        ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
        GH_TOKEN: ${{ secrets.GH_TOKEN }}
  do-the-job:
    needs: start-runner # required to start the main job when the runner is ready
        runs-on: ${{ needs.create.outputs.uniq_label }} # run the job on the newly created runner
        steps:
          - name: Hello World
            run: echo 'Hello World from Azure!'
  stop-runner:
    needs: do-the-job # required to wait when the main job is done
    uses: Jason-Clark-FG/azure-github-runner/.github/workflows/delete.yml@v1
    if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
    secrets:
      ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
      ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
      ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
      ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
      GH_TOKEN: ${{ secrets.GH_TOKEN }}

You also have an example at test_create.yml