Skip to content

[INFRA] fix autoupdate contributors #50

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

Merged
merged 3 commits into from
Jun 18, 2022
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
63 changes: 13 additions & 50 deletions .github/workflows/update-contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
push:
branches:
- main
- dev

jobs:
Update:
Expand Down Expand Up @@ -38,53 +37,17 @@ jobs:
# the minimum number of contributions required to add a user
threshold: 1

- name: Checkout New Branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_AGAINST: "main"
run: |
printf "GitHub Actor: ${GITHUB_ACTOR}\n"
export BRANCH_FROM="contributors/update-$(date '+%Y-%m-%d')"
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"

BRANCH_EXISTS=$(git ls-remote --heads origin ${BRANCH_FROM})
if [[ -z ${BRANCH_EXISTS} ]]; then
printf "Branch does not exist in remote.\n"
else
printf "Branch already exists in remote.\n"
exit 1
fi
git branch
git checkout -b "${BRANCH_FROM}" || git checkout "${BRANCH_FROM}"
git branch

git config --global user.name "github-actions"
git config --global user.email "[email protected]"

git status

# Make sure to add new files or path/*
git add .tributors
git add README.md
git add .all-contributorsrc

if git diff-index --quiet HEAD --; then
export OPEN_PULL_REQUEST=0
printf "No changes\n"
else
export OPEN_PULL_REQUEST=1
printf "Changes\n"
git commit -a -m "Automated deployment to update contributors $(date '+%Y-%m-%d')"
git push origin "${BRANCH_FROM}"
fi
echo "::set-env name=OPEN_PULL_REQUEST::${OPEN_PULL_REQUEST}"
echo "::set-env name=PULL_REQUEST_FROM_BRANCH::${BRANCH_FROM}"
echo "::set-env name=PULL_REQUEST_TITLE::[tributors] ${BRANCH_FROM}"
echo "::set-env name=PULL_REQUEST_BODY::Updating tributors automated pull request."
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
commit-message: BIDS schema update
base: main
delete-branch: true
title: '[BOT] update git submodules'
body: 'done via this [GitHub Action](https://github.com/cpp-lln-lab/CPP_ROI/blob/main/.github/workflows/update-contributors.yml)'

- name: Open Pull Request
uses: vsoch/[email protected]
if: ${{ env.OPEN_PULL_REQUEST == '1' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST_BRANCH: "master"
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"