Benchmark Cleanup #2362
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: Benchmark Cleanup | |
on: | |
schedule: | |
- cron: "0 * * * *" # Every hour | |
workflow_call: | |
inputs: | |
state: | |
description: "state: Deletion target benchmark state. Despite of state, expired benchmark environments are always deleted." | |
required: false | |
default: "Failed" # default should be 'Failed' for workflow_call, safe guard. | |
type: string | |
try-redeploy: | |
description: "try-redeploy: Try Redeploy before deletion only if scheduled" | |
required: false | |
default: false | |
type: boolean | |
no-delete: | |
description: "no-delete: Skip delete, you can just update environment with try-redeploy" | |
required: false | |
default: false | |
type: boolean | |
workflow_dispatch: | |
inputs: | |
state: | |
description: "state: Deletion target benchmark state. Despite of state, expired benchmark environments are always deleted." | |
required: false | |
default: "All" | |
type: choice | |
options: | |
- Failed | |
- Succeeded | |
- All | |
try-redeploy: | |
description: "try-redeploy: Try Redeploy before deletion only if scheduled" | |
required: false | |
default: false | |
type: boolean | |
no-delete: | |
description: "no-delete: Skip delete, you can just update environment with try-redeploy" | |
required: false | |
default: false | |
type: boolean | |
env: | |
GH_REPO: ${{ github.repository }} # gh cli handling | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # gh cli handling | |
permissions: | |
contents: read | |
id-token: write | |
pull-requests: write | |
issues: write | |
jobs: | |
cleanup: | |
name: "Cleanup ${{matrix.state}} (redeploy: ${{ matrix.try-redeploy}})" | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- benchmark-devcenter: ade-devcenter-jp # Benchmark devcenter name | |
benchmark-project: ade-project-jp # Benchmark project name | |
state: ${{ inputs.state || 'Failed' }} # Failed benchmark environment is deletion target | |
try-redeploy: ${{ github.event_name == 'schedule' || inputs.try-redeploy }} # Try Redeploy before deletion only if scheduled | |
no-delete: ${{ inputs.no-delete || 'false' }} # Skip delete, you can just update environment with try-redeploy | |
environment: | |
name: benchmark | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: "Cysharp/Actions" | |
path: Actions | |
- name: List checkout repos | |
run: ls -l | |
- name: Load secret | |
id: op-load-secret | |
uses: 1password/load-secrets-action@v2 | |
with: | |
export-env: false | |
env: | |
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN_PUBLIC }} | |
AZURE_OIDC_CLIENTID: "op://GitHubActionsPublic/BENCHMARK_AZURE_OIDC/clientId" | |
AZURE_OIDC_TENANTID: "op://GitHubActionsPublic/BENCHMARK_AZURE_OIDC/tenantId" | |
AZURE_OIDC_SUBSCRIPTIONID: "op://GitHubActionsPublic/BENCHMARK_AZURE_OIDC/subscriptionId" | |
- uses: azure/login@v2 | |
with: | |
client-id: ${{ steps.op-load-secret.outputs.AZURE_OIDC_CLIENTID }} | |
tenant-id: ${{ steps.op-load-secret.outputs.AZURE_OIDC_TENANTID }} | |
subscription-id: ${{ steps.op-load-secret.outputs.AZURE_OIDC_SUBSCRIPTIONID }} | |
- name: Add Azure CLI devcenter extension | |
run: az extension add --name devcenter --upgrade | |
- name: Cleanup benchmark environment | |
run: bash ./scripts/benchmark_environment_clean.sh --dev-center-name '${{ matrix.benchmark-devcenter }}' --project-name '${{ matrix.benchmark-project }}' --state ${{ matrix.state }} --dry-run false --try-redeploy ${{ matrix.try-redeploy }} --no-delete "${{ matrix.no-delete }}" | |
working-directory: ./Actions/.github |