├── .github └── workflows │ └── tip.yml └── README.md /.github/workflows/tip.yml: -------------------------------------------------------------------------------- 1 | name: Suggest A Tip 2 | run-name: How much do you want to tip ${{ github.actor }}? 3 | on: [pull_request] 4 | jobs: 5 | suggest_tips: 6 | permissions: 7 | pull-requests: write 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | with: 12 | fetch-depth: 0 13 | - name: Calculate the lines changed & the tip options. 14 | id: count-lines 15 | run: | 16 | changed_lines=$(git diff --shortstat origin/main origin/${GITHUB_HEAD_REF} | awk '{s+=$4} {s+=$6} END {print s}') 17 | opt_one=$(printf "%.2f" "$changed_lines") 18 | opt_two=$(printf "%.2f" "$(echo "$changed_lines * 0.75" | bc)") 19 | opt_three=$(printf "%.2f" "$(echo "$changed_lines * 0.50" | bc)") 20 | echo "ONE=$opt_one" >> $GITHUB_ENV 21 | echo "TWO=$opt_two" >> $GITHUB_ENV 22 | echo "THREE=$opt_three" >> $GITHUB_ENV 23 | - name: Comment the tip options on the PR. 24 | uses: thollander/actions-comment-pull-request@v2 25 | with: 26 | message: | 27 | Please choose an option to tip: 28 | 29 | |