Skip to content

integration-cleanup #8616

integration-cleanup

integration-cleanup #8616

name: integration-cleanup
on:
workflow_dispatch:
schedule:
- cron: "0 * * * *"
permissions:
id-token: write # Required for obtaining AWS OIDC federated credential.
env:
GCRGC_VERSION: 0.4.8
jobs:
gcp:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./tools/reaper
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: fluxcd/test-infra
- name: Setup Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version: 1.23.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@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
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@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f # v2.1.7
with:
credentials_json: '${{ secrets.CLEANUP_E2E_GOOGLE_CREDENTIALS }}'
- name: Setup gcloud
uses: google-github-actions/setup-gcloud@6189d56e4096ee891640bb02ac264be376592d6a # v2.1.2
- 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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: fluxcd/test-infra
- name: Setup Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version: 1.23.x
cache-dependency-path: ./tools/reaper/go.sum
- name: Authenticate to Azure
uses: Azure/login@a65d910e8af852a8061c627c456678983e180302 # 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
aws:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./tools/reaper
if: true
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: fluxcd/test-infra
- name: Setup Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version: 1.23.x
cache-dependency-path: ./tools/reaper/go.sum
- name: Authenticate to AWS
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.CLEANUP_E2E_AWS_ASSUME_ROLE_NAME }}
role-session-name: cleanup_GH_Actions
aws-region: ${{ vars.AWS_REGION }}
- name: Run reaper
run: go run ./ -provider aws-nuke -awsregions '${{ vars.AWS_REGION }},${{ vars.OCI_E2E_TF_VAR_cross_region }}' -retention-period 1h -tags 'ci=true' -delete