Recreate Linux self-hosted runners on schedule #928
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Recreate Linux self-hosted runners on schedule | |
on: | |
workflow_dispatch: | |
schedule: | |
# Once each 24 hours, at 1 during the night | |
- cron: "0 1 * * *" | |
concurrency: | |
group: recreate-linux-runners | |
cancel-in-progress: true | |
jobs: | |
recreate: | |
if: github.repository == 'Homebrew/homebrew-core' | |
runs-on: ubuntu-latest | |
env: | |
# TODO agree on one label for all runners | |
RUNNER_LABEL: TODO | |
strategy: | |
matrix: | |
runner_name: | |
- linux-self-hosted-1 | |
steps: | |
- name: Set up Cloud SDK | |
uses: google-github-actions/[email protected] | |
with: | |
project_id: ${{ secrets.GCP_PROJECT_ID }} | |
service_account_key: ${{ secrets.GCP_SA_KEY }} | |
export_default_credentials: true | |
- name: Wait for idle runner | |
id: killable | |
uses: Homebrew/actions/wait-for-idle-runner@master | |
with: | |
runner_name: ${{ matrix.runner_name }} | |
github_token: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }} | |
- name: Kill runner and create a new one | |
if: ${{ steps.killable.outputs.runner-found == 'true' && steps.killable.outputs.runner-idle == 'true' }} | |
uses: Homebrew/actions/create-gcloud-instance@master | |
with: | |
runner_name: ${{ matrix.runner_name }} | |
gcp_project_id: ${{ secrets.GCP_PROJECT_ID }} | |
gcp_service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }} | |
gcp_sa_key: ${{ secrets.GCP_SA_KEY }} | |
github_token: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }} |