Skip to content

Commit 2cb7447

Browse files
committed
MAINT: Add auto-push for bots
1 parent a26061c commit 2cb7447

3 files changed

Lines changed: 49 additions & 9 deletions

File tree

.github/workflows/autopush.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Bot auto-push
2+
on: # yamllint disable-line rule:truthy
3+
push:
4+
branches:
5+
- dependabot/*
6+
- pre-commit-ci/*
7+
- credit/*
8+
# TODO: REMOVE THIS
9+
- autopush
10+
11+
jobs:
12+
autobot:
13+
permissions:
14+
contents: write
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v5
18+
with:
19+
persist-credentials: true
20+
token: ${{ secrets.MNE_BOT_TOKEN }}
21+
ssh-user: mne-bot
22+
fetch-depth: 0
23+
- name: Push a commit for bot PRs to run CircleCI
24+
run: |
25+
set -xeo pipefail
26+
git config --global user.name "mne[bot]"
27+
git config --global user.email "mne-bot@noreply.github.com"
28+
COMMIT_MESSAGE=$(git show -s --format=%s)
29+
# Detect dependabot and pre-commit.ci commit messages
30+
# mne-bot PRs (SPEC0, credit) shouldn't need it since we commit with mne-bot user
31+
if [[ "$COMMIT_MESSAGE" == 'Bump '* ]] || [[ "$COMMIT_MESSAGE" == '[pre-commit.ci]'* ]] || [[ "$COMMIT_MESSAGE" == "TST: Ping [skip azp]" ]]; then
32+
echo "Pushed commit to run CircleCI for: $COMMIT_MESSAGE" | tee -a $GITHUB_STEP_SUMMARY
33+
git commit --allow-empty -m "mne[bot] Push commit to run CircleCI"
34+
gh push
35+
else:
36+
echo "No need to push a commit for: $COMMIT_MESSAGE" | tee -a $GITHUB_STEP_SUMMARY
37+
fi
38+
env:
39+
GH_TOKEN: ${{ secrets.MNE_BOT_TOKEN }}

.github/workflows/credit.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ jobs:
3535
- name: Create PR
3636
run: |
3737
set -xeo pipefail
38-
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
39-
git config --global user.name "github-actions[bot]"
40-
git checkout -b credit
41-
git commit -am "MAINT: Update code credit"
42-
git push origin credit
43-
PR_NUM=$(gh pr create --base main --head credit --title "MAINT: Update code credit" --body "Created by credit [GitHub action](https://github.com/mne-tools/mne-python/actions/runs/${{ github.run_id }}). <br> <br> *Adjustments may need to be made to \`doc/changes/credit_tools.py\` or \`.mailmap\` etc. to get CircleCI to pass.*" --label "no-changelog-entry-needed")
38+
git config --global user.email "50266005+mne-bot@users.noreply.github.com"
39+
git config --global user.name "mne[bot]"
40+
BRANCH=credit/$GITHUB_RUN_ID
41+
git checkout -b $BRANCH
42+
git commit -am "mne[bot]: Update code credit"
43+
git push origin $BRANCH
44+
PR_NUM=$(gh pr create --base main --head $BRANCH --title "MAINT: Update code credit" --body "Created by credit [GitHub action](https://github.com/mne-tools/mne-python/actions/runs/${{ github.run_id }}). <br> <br> *Adjustments may need to be made to \`doc/changes/credit_tools.py\` or \`.mailmap\` etc. to get CircleCI to pass.*" --label "no-changelog-entry-needed")
4445
echo "Opened https://github.com/mne-tools/mne-python/pull/${PR_NUM}" >> $GITHUB_STEP_SUMMARY
4546
if: steps.status.outputs.dirty == 'true'

.github/workflows/spec_zero.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ jobs:
5252
- name: Create PR
5353
run: |
5454
set -xeo pipefail
55-
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
56-
git config --global user.name "github-actions[bot]"
55+
git config --global user.email "50266005+mne-bot@users.noreply.github.com"
56+
git config --global user.name "mne[bot]"
5757
git checkout -b spec_zero
58-
git commit -am "MAINT: Update dependency specifiers"
58+
git commit -am "mne[bot]: Update dependency specifiers"
5959
git push origin spec_zero
6060
PR_NUM=$(gh pr create --base main --head spec_zero --title "MAINT: Update dependency specifiers" --body "Created by spec_zero [GitHub action](https://github.com/mne-tools/mne-python/actions/runs/${{ github.run_id }}). <br> <br> *Adjustments may need to be made to shims in \`mne/fixes.py\` in this or another PR. \`git grep TODO VERSION\` is a good starting point for finding potential updates.*" --label "no-changelog-entry-needed")
6161
echo "Opened https://github.com/mne-tools/mne-python/pull/${PR_NUM}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)