diff --git a/.github/workflows/auto-add-contributors.yml b/.github/workflows/auto-add-contributors.yml index 706d0693..756bb6a4 100644 --- a/.github/workflows/auto-add-contributors.yml +++ b/.github/workflows/auto-add-contributors.yml @@ -31,12 +31,12 @@ jobs: python -m pip install --upgrade pip pip install -r .github/workflows/contributors/requirements.txt - - name: Retrieving contributors for commit ${{ github.sha }} + - name: Retrieving all contributors from the main branch run: | echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" echo "🔎 Getting all contributors from the ${{ github.ref }} branch." - PUSHED_CONTRIBUTORS=$(git shortlog -sne --no-merges ${{ github.event.before }}..${{ github.sha }}) + PUSHED_CONTRIBUTORS=$(git shortlog -sne --no-merges main) echo "The contributors are: $PUSHED_CONTRIBUTORS" - name: Running Python Script to Update .all-contributorsrc run: | @@ -51,6 +51,11 @@ jobs: npx all-contributors generate git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" + + # Fetch the latest state of the master branch and try to merge + git fetch origin main + git merge origin/main + git add -u git diff-index --quiet HEAD || git commit -m "Update readme and contributors.qmd with contributors" - git push \ No newline at end of file + git push diff --git a/.github/workflows/contributors/update_contributors.py b/.github/workflows/contributors/update_contributors.py index 6032034b..2acae10a 100644 --- a/.github/workflows/contributors/update_contributors.py +++ b/.github/workflows/contributors/update_contributors.py @@ -5,14 +5,13 @@ from github import Github import requests -CONTRIBUTORS_TMP_FILE = 'CONTRIBUTORS_TEMP.txt' CONTRIBUTORS_FILE = '.all-contributorsrc' -EXCLUDED_USERS = ['web-flow'] +EXCLUDED_USERS = ['web-flow', 'github-actions[bot]', 'mrdragonbear'] OWNER = "harvard-edge" REPO = "cs249r_book" -BRANCH = "auto_contributor" +BRANCH = "main" def split_name_email(s):