Merge pull request #516 from Sara-Khosravi/edit-security-chapter-F #730
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Automatically Add Contributors | |
on: | |
push: | |
branches: | |
- main | |
- contrib_test | |
- dev | |
jobs: | |
update-contributors: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- name: Installing GitHub CLI | |
run: | | |
sudo apt -y update && sudo apt -y upgrade | |
sudo apt -y install software-properties-common | |
sudo apt install -y gh jq nodejs npm | |
- name: Install python packages | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r .github/workflows/contributors/requirements.txt | |
- name: Auto add contributor job has been triggered | |
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!" | |
- name: Running Python Script to Update .all-contributorsrc and Using all-contributors CLI to update files | |
run: | | |
echo "Using all-contributors CLI to update files" | |
npm i -D all-contributors-cli | |
# Configure Git | |
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 current branch from the remote | |
git fetch origin $GITHUB_REF_NAME | |
git reset --hard origin/$GITHUB_REF_NAME | |
# Run the script | |
python .github/workflows/contributors/update_contributors.py | |
npx all-contributors generate | |
# Add updates | |
git add -u | |
# Commit and push if there are changes | |
git diff-index --quiet HEAD || git commit -m "Update readme and contributors.qmd with contributors" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |