replaced hexa and rgb colors with theme palettes and tokens #1
Workflow file for this run
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: Add new contributor to AUTHORS.md | |
on: | |
pull_request: | |
types: [opened] | |
jobs: | |
check_contributor_exists: | |
runs-on: ubuntu-latest | |
outputs: | |
is_contributor_in_file: ${{ steps.check_contributor_step.outputs.exists }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
sparse-checkout: . | |
- name: Check if contributor already exists | |
id: check_contributor_step | |
run: | | |
exists=$(grep -c -F "${{ github.event.pull_request.user.login }}" AUTHORS.md || true) | |
if [[ $exists -gt 0 ]]; then | |
echo "exists=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "exists=false" >> "$GITHUB_OUTPUT" | |
fi | |
add_contributor: | |
runs-on: ubuntu-latest | |
needs: check_contributor_exists | |
if: needs.check_contributor_exists.outputs.is_contributor_in_file == 'false' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Get contributor's full name and append to AUTHORS.md file | |
run: | | |
username=${{ github.event.pull_request.user.login }} | |
full_name=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/users/$username" | jq -r '.name') | |
if [[ "$full_name" == "" || "$full_name" == "null" ]]; then | |
full_name='-' | |
fi | |
echo "| $full_name | $username |" >> AUTHORS.md | |
- name: Commit and push changes to the contributor's PR branch | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git add AUTHORS.md | |
git commit -m "Add ${{ github.event.pull_request.user.login }} to AUTHORS.md" | |
git push origin ${{ github.head_ref }} |