integration-cleanup #117
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: integration-cleanup | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" | |
permissions: {} | |
env: | |
GCRGC_VERSION: 0.4.8 | |
jobs: | |
gcp: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./tools/reaper | |
steps: | |
- name: Checkout | |
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 | |
with: | |
repository: fluxcd/test-infra | |
- name: Setup Go | |
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 | |
with: | |
go-version: 1.20.x | |
cache-dependency-path: ./tools/reaper/go.sum | |
- name: Setup bin dir | |
run: mkdir -p ~/.local/bin | |
- name: Populate local env | |
# This is needed to be able to use the global env as local env in cache | |
# key. | |
run: echo "GCRGC_VERSION=${GCRGC_VERSION}" >> $GITHUB_ENV | |
- name: Cache gcrgc | |
id: cache-gcrgc | |
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 | |
with: | |
path: ~/.local/bin/gcrgc | |
key: gcrgc-${{ env.GCRGC_VERSION }} | |
- name: Install gcrgc | |
if: steps.cache-gcrgc.outputs.cache-hit != 'true' | |
run: | | |
cd $(mktemp -d) | |
wget https://github.com/graillus/gcrgc/releases/download/v${GCRGC_VERSION}/gcrgc_${GCRGC_VERSION}_linux_amd64.tar.gz -O - | tar xz | |
mv gcrgc ~/.local/bin/ | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033 # v1.1.1 | |
with: | |
credentials_json: '${{ secrets.CLEANUP_E2E_GOOGLE_CREDENTIALS }}' | |
- name: Setup gcloud | |
uses: google-github-actions/setup-gcloud@e30db14379863a8c79331b04a9969f4c1e225e0b # v1.1.1 | |
- name: Run gcrgc | |
# Cleanup all the GCR repositories in the project. They are not tracked | |
# by terraform used to provision test infra and are left behind. | |
run: gcrgc gcr.io/${{ vars.TF_VAR_gcp_project_id }} | |
- name: Run reaper | |
# NOTE: This is in dry-run mode by default. Pass `-delete` to allow it | |
# to delete. | |
run: go run ./ -provider gcp -gcpproject ${{ vars.TF_VAR_gcp_project_id }} -retention-period 1d -tags 'ci=true' | |
azure: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./tools/reaper | |
if: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 | |
with: | |
repository: fluxcd/test-infra | |
- name: Setup Go | |
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 | |
with: | |
go-version: 1.20.x | |
cache-dependency-path: ./tools/reaper/go.sum | |
- name: Authenticate to Azure | |
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.6 | |
with: | |
creds: '{"clientId":"${{ secrets.CLEANUP_E2E_AZ_ARM_CLIENT_ID }}","clientSecret":"${{ secrets.CLEANUP_E2E_AZ_ARM_CLIENT_SECRET }}","subscriptionId":"${{ secrets.CLEANUP_E2E_AZ_ARM_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.CLEANUP_E2E_AZ_ARM_TENANT_ID }}"}' | |
- name: Run reaper | |
# NOTE: This is in dry-run mode by default. Pass `-delete` to allow it | |
# to delete. | |
run: go run ./ -provider azure -retention-period 1d -tags 'ci=true' |