Skip to content
This repository was archived by the owner on Mar 1, 2025. It is now read-only.

Update auto-bot.yaml #107

Update auto-bot.yaml

Update auto-bot.yaml #107

Workflow file for this run

name: Repo Management
on:
pull_request_target:
types: [closed]
# schedule:
# - cron: "0 0 * * *" # 每天午夜运行
push:
branches: [main] # 每次推送到main分支时也运行
permissions:
contents: write
pull-requests: write
jobs:
# invite-contributor:
# runs-on: ubuntu-latest
# if: github.event_name == 'pull_request_target' && github.event.pull_request.merged == true
# steps:
# - name: Invite contributor
# id: invite-contributor
# uses: actions/github-script@v6
# with:
# github-token: ${{ secrets.PAT_WITH_INVITE_PERMISSIONS }}
# script: |
# const { owner, repo } = context.repo;
# const username = context.payload.pull_request.user.login;
# console.log(`Checking if ${username} is already a collaborator...`);
# try {
# const { data: permissionLevel } = await github.rest.repos.getCollaboratorPermissionLevel({
# owner,
# repo,
# username,
# });
# if (permissionLevel.permission === 'admin' || permissionLevel.permission === 'write') {
# console.log(`${username} is already a collaborator with sufficient permissions.`);
# return;
# }
# console.log(`${username} is a collaborator but needs permission update.`);
# } catch (error) {
# if (error.status !== 404) {
# console.error(`Error checking collaborator status: ${error.message}`);
# throw error;
# }
# console.log(`${username} is not a collaborator.`);
# }
# try {
# console.log(`Inviting ${username} as a collaborator...`);
# const response = await github.rest.repos.addCollaborator({
# owner,
# repo,
# username,
# permission: 'push'
# });
# if (response.status === 201) {
# console.log(`Invitation sent to ${username} as a collaborator with push permission.`);
# core.setOutput('invitation_sent', 'true');
# } else if (response.status === 204) {
# console.log(`${username}'s permissions updated to push.`);
# core.setOutput('invitation_sent', 'false');
# }
# } catch (error) {
# console.error(`Error inviting/updating collaborator: ${error.message}`);
# core.setFailed(`Error inviting/updating collaborator: ${error.message}`);
# }
# - name: Comment on PR
# if: steps.invite-contributor.outputs.invitation_sent == 'true'
# uses: actions/github-script@v6
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# script: |
# const { owner, repo } = context.repo;
# const issue_number = context.payload.pull_request.number;
# const username = context.payload.pull_request.user.login;
# try {
# await github.rest.issues.createComment({
# owner,
# repo,
# issue_number,
# body: `Thanks for your contribution, @${username}! You've been invited as a collaborator with push permissions. Please check your email for the invitation.`
# });
# console.log(`Comment posted on PR #${issue_number}`);
# } catch (error) {
# console.error(`Error posting comment: ${error.message}`);
# core.setFailed(`Error posting comment: ${error.message}`);
# }
# update-readme:
# runs-on: ubuntu-latest
# if: github.event_name == 'schedule' || github.event_name == 'push'
# steps:
# - uses: actions/checkout@v2
# - name: Set up Python
# uses: actions/setup-python@v2
# with:
# python-version: "3.x"
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install PyGithub pytz
# - name: Update README
# env:
# # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# START_DATE: ${{ vars.START_DATE }}
# END_DATE: ${{vars.END_DATE }}
# FILE_SUFFIX: ${{vars.FILE_SUFFIX}}
# FIELD_NAME: ${{vars.FIELD_NAME}}
# run: python async_readme.py
# - name: Check for changes
# id: git-check
# run: |
# git diff --exit-code README.md || echo "modified=true" >> $GITHUB_OUTPUT
# - name: Commit changes
# if: steps.git-check.outputs.modified == 'true'
# run: |
# git config --local user.email "action@github.com"
# git config --local user.name "GitHub Action"
# git add README.md
# git commit -m "Update commit status table"
# git push
# - name: Notify server
# if: github.event_name == 'push'
# env:
# SERVER_URL: ${{ secrets.SERVER_URL }}
# run: |
# REPO_NAME=$(echo "${{ github.repository }}" | awk -F '/' '{print $2}')
# curl -X POST $SERVER_URL/trigger \
# -H "Content-Type: application/json" \
# -d "{
# \"username\": \"${{ github.actor }}\",
# \"repository\": \"$REPO_NAME\"
# }"