Skip to content

integration-cleanup #2994

integration-cleanup

integration-cleanup #2994

name: integration-cleanup
on:
workflow_dispatch:
schedule:
- cron: "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@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
repository: fluxcd/test-infra
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: 1.22.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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
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@55bd3a7c6e2ae7cf1877fd1ccb9d54c0503c457c # v2.1.2
with:
credentials_json: '${{ secrets.CLEANUP_E2E_GOOGLE_CREDENTIALS }}'
- name: Setup gcloud
uses: google-github-actions/setup-gcloud@98ddc00a17442e89a24bbf282954a3b65ce6d200 # v2.1.0
- 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 }} --retention-period 1h
- name: Run reaper
run: go run ./ -provider gcp -gcpproject ${{ vars.TF_VAR_gcp_project_id }} -retention-period 1h -tags 'ci=true' -delete
azure:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./tools/reaper
if: false
steps:
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
repository: fluxcd/test-infra
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: 1.22.x
cache-dependency-path: ./tools/reaper/go.sum
- name: Authenticate to Azure
uses: Azure/login@6b2456866fc08b011acb422a92a4aa20e2c4de32 # 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
run: go run ./ -provider azure -retention-period 1h -tags 'ci=true' -delete