-
Notifications
You must be signed in to change notification settings - Fork 194
63 lines (54 loc) · 2.17 KB
/
CleanupTempRepos.yaml
File metadata and controls
63 lines (54 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Cleanup Temp Repos
on:
workflow_dispatch:
inputs:
githubOwner:
description: GitHub organization set as owner for the temp repositories (default is to use your personal account)
required: false
default: ''
workflow_run:
workflows: [End to end tests]
types:
- completed
defaults:
run:
shell: pwsh
permissions:
contents: read
jobs:
CleanupRepos:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} # Run only if dispatched or the End to end tests workflow has succeeded
runs-on: [ ubuntu-latest ]
name: Cleanup Temp Repos
steps:
- name: Harden Runner
if: github.repository_owner == 'microsoft'
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- name: Check E2E app is set up
run: |
if (('${{ vars.E2E_APP_ID }}' -eq '') -or ('${{ secrets.E2E_PRIVATE_KEY }}' -eq '')) {
Write-Host "::Error:: In order to clean up the temp repositories you must have a secret called E2E_PRIVATE_KEY and a variable called E2E_APP_ID defined in your repository."
exit 1
}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Get GitHub Owner
id: getGitHubOwner
env:
githubOwner: ${{ github.event.inputs.githubOwner }}
run: |
${{ github.workspace }}/Internal/Scripts/GetOwnerForE2ETests.ps1 -githubOwner $env:githubOwner
- uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
id: app-token
if: ${{ vars.E2E_APP_ID != '' }}
with:
app-id: ${{ vars.E2E_APP_ID }}
private-key: ${{ secrets.E2E_PRIVATE_KEY }}
owner: ${{ steps.getGitHubOwner.outputs.githubOwner }}
- name: Cleanup Temp Repositories
env:
githubOwner: ${{ steps.getGitHubOwner.outputs.githubOwner }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
${{ github.workspace }}/Internal/Scripts/RemoveTempRepos.ps1 -githubOwner $env:githubOwner