Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uses Python instead of JS on Housekeep Actions #688

Merged
merged 2 commits into from
Feb 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 10 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,17 @@ jobs:
name: Housekeep
runs-on: ubuntu-latest
steps:
- name: Install Node packages
run: sudo npm install -g octokit
- name: Update PRs
run: |
import { Octokit } from 'octokit';
from datetime import datetime
from github import Auth, Github

const octokit = new Octokit({ auth: '${{ secrets.GITHUB_TOKEN }}' });
const owner = '${{ github.event.repository.owner.login }}';
const repo = '${{ github.event.repository.name }}';
const resp = await octokit.request('GET /repos/{owner}/{repo}/pulls', {
owner,
repo,
base: '${{ github.ref_name }}',
sort: 'updated',
direction: 'desc',
per_page: 100,
});
now = datetime.now()
gh = Github(auth=Auth.Token("${{ secrets.GITHUB_TOKEN }}"))
repo = gh.get_repo("${{ github.repository }}")

for (const pull of resp.data) {
await octokit.request('POST /repos/{owner}/{repo}/issues/{issue_number}/labels', {
owner,
repo,
issue_number: pull.number,
labels: ['B-out-of-date'],
});
}
shell: node --experimental-default-type=module {0}
for pull in repo.get_pulls("open", "updated", "desc", "${{ github.ref_name }}"):
if (now - pull.updated_at).days > 30:
break
pull.add_to_labels("B-out-of-date")
shell: python