Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
mattops committed Jan 10, 2025
1 parent 18b66aa commit b6359c2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 29 deletions.
46 changes: 30 additions & 16 deletions .github/actions/runner-cleanup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,36 @@ runs:
auth = Auth.Token(os.getenv('gh_auth_token'))
print(f'Repo name is: {github_org}')
g = Github(auth=auth)
repo = g.get_repo(github_org)
offline_deleted=False
qty_runners=retry_count=0
while qty_runners!=expected_number_of_runners and retry_count < 10:
try:
runners = repo.get_self_hosted_runners()
qty_runners=runners.totalCount
print(f'Attempt to clean up offline runners: {retry_count} - found {qty_runners} runners')
for each_runner in runners:
print(f'Checking runner {each_runner.name} with status {each_runner.status}')
if each_runner.status == 'offline':
success=repo.remove_self_hosted_runner(each_runner.id)
except:
print(f'Failed because {GithubException.message}')
retry_count+=1
sleep(10)
# Calling unsupported PyGithub API endpoint
url = f"https://api.github.com/orgs/{github_org}/actions/runners"
headers = {
"Authorization": f"Bearer {auth_token}",
"Accept": "application/vnd.github+json"
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
print("Successfully called GET /orgs/{github_org}/actions/runners runners endpoint")
data = response.json()
# Process the data as needed
else:
print(f"Failed to call GET /orgs/{github_org}/actions/runners endpoint: {response.status_code} - {response.text}")
# repo = g.get_repo(github_org)
# offline_deleted=False
# qty_runners=retry_count=0
# while qty_runners!=expected_number_of_runners and retry_count < 10:
# try:
# runners = repo.get_self_hosted_runners()
# qty_runners=runners.totalCount
# print(f'Attempt to clean up offline runners: {retry_count} - found {qty_runners} runners')
# for each_runner in runners:
# print(f'Checking runner {each_runner.name} with status {each_runner.status}')
# if each_runner.status == 'offline':
# success=repo.remove_self_hosted_runner(each_runner.id)
# except:
# print(f'Failed because {GithubException.message}')
# retry_count+=1
# sleep(10)
if __name__ == '__main__':
main()
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ jobs:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}

- name: Deploy to Platform
uses: ./.github/actions/cloud-platform-deploy
with:
environment: ${{ inputs.environment }}
version: ${{ inputs.version }}
api: https://${{ secrets.KUBE_CLUSTER }}
cert: ${{ secrets.KUBE_CERT }}
cluster: ${{ secrets.KUBE_CLUSTER }}
namespace: ${{ secrets.KUBE_NAMESPACE }}
token: ${{ secrets.KUBE_TOKEN }}
gh_auth_token: ${{ steps.generate-github-app-tokens.outputs.access-token }}
github_org: ${{ github.repository_owner }}
runner_labels: ${{ vars.RUNNER_LABELS }}
# - name: Deploy to Platform
# uses: ./.github/actions/cloud-platform-deploy
# with:
# environment: ${{ inputs.environment }}
# version: ${{ inputs.version }}
# api: https://${{ secrets.KUBE_CLUSTER }}
# cert: ${{ secrets.KUBE_CERT }}
# cluster: ${{ secrets.KUBE_CLUSTER }}
# namespace: ${{ secrets.KUBE_NAMESPACE }}
# token: ${{ secrets.KUBE_TOKEN }}
# gh_auth_token: ${{ steps.generate-github-app-tokens.outputs.access-token }}
# github_org: ${{ github.repository_owner }}
# runner_labels: ${{ vars.RUNNER_LABELS }}

- name: Remove offline runners
uses: ./.github/actions/runner-cleanup
Expand Down

0 comments on commit b6359c2

Please sign in to comment.