Skip to content

Commit

Permalink
Create cleanup.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh authored Feb 23, 2024
1 parent 62b87d2 commit 79521c7
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Clean Up

on:
workflow_dispatch:
inputs:
members:
description: 'The members added to the org recently (JSON Array)'
required: false
default: '[]'
repository-collaborators:
description: 'The repository collaborators added to the org recently (JSON Map)'
required: false
default: '{}'
team-members:
description: 'The team members added to the org recently (JSON Map)'
required: false
default: '{}'
cutoff:
description: 'The number of months to consider for inactivity'
required: false
default: '12'

defaults:
run:
shell: bash

jobs:
sync:
permissions:
contents: read
name: Sync
runs-on: ubuntu-latest
env:
GITHUB_APP_ID: ${{ secrets.RO_GITHUB_APP_ID }}
GITHUB_APP_INSTALLATION_ID: ${{ secrets[format('RO_GITHUB_APP_INSTALLATION_ID_{0}', github.repository_owner)] || secrets.RO_GITHUB_APP_INSTALLATION_ID }}
GITHUB_APP_PEM_FILE: ${{ secrets.RO_GITHUB_APP_PEM_FILE }}
TF_WORKSPACE: ${{ github.repository_owner }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Initialize scripts
run: npm install && npm run build
working-directory: scripts
- name: Remove inactive members
run: node lib/actions/remove-inactive-members.js
working-directory: scripts
env:
NEW_MEMBERS: ${{ github.event.inputs.members }}
NEW_REPOSITORY_COLLABORATORS: ${{ github.event.inputs['repository-collaborators'] }}
NEW_TEAM_MEMBERS: ${{ github.event.inputs['team-members'] }}
CUTOFF_IN_MONTHS: ${{ github.event.inputs.cutoff }}
- name: Check if github was modified
id: github-modified
run: |
if [ -z "$(git status --porcelain -- github)" ]; then
echo "this=false" >> $GITHUB_OUTPUT
else
echo "this=true" >> $GITHUB_OUTPUT
fi
- uses: ./.github/actions/git-config-user
if: steps.github-modified.outputs.this == 'true'
- if: steps.github-modified.outputs.this == 'true'
run: |
git add --all -- github
git commit -m "cleanup@${GITHUB_RUN_ID}"
git checkout -B "${GITHUB_REF_NAME}-${SUFFIX}"
git push origin "${GITHUB_REF_NAME}-${SUFFIX}" --force

0 comments on commit 79521c7

Please sign in to comment.