integration-cleanup #129
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@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
with: | |
repository: fluxcd/test-infra | |
- name: Setup Go | |
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | |
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@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.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@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@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
with: | |
repository: fluxcd/test-infra | |
- name: Setup Go | |
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | |
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' |