Skip to content

Update NPS

Update NPS #1160

Workflow file for this run

name: Update NPS
on:
workflow_dispatch:
schedule:
- cron: '0 */12 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Update this repo's README
uses: JasonEtco/rss-to-readme@v1
with:
feed-url: https://keithcirkel.co.uk/feed.xml
readme-section: feed
empty-commits: "false"
- uses: actions/checkout@v3
- name: Update NPS in readme
run: |
res=$(curl -s "${{ secrets.NPS_SHEETS_URL }}")
total=$(echo "$res" | jq '.[]["How likely are you to recommend working with Keith to colleagues?"]' | wc -l)
promoters=$(echo "$res" | jq '.[]["How likely are you to recommend working with Keith to colleagues?"]|tonumber|select(.>=9)' | wc -l)
detractors=$(echo "$res" | jq '.[]["How likely are you to recommend working with Keith to colleagues?"]|tonumber|select(.<=6)' | wc -l)
nps=$(bc <<< "scale=2; (${promoters:-0}-${dectrators:-0})/${total:-0} * 100")
echo "Total: $total, Promoters: $promoters, Detractors: $detractors. NPS: $nps"
echo
sed -i "s|\(<!--nps-->\)[^<]\+\(<!--/nps-->\)|\1${nps:-0}\2|g" README.md
cat README.md
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add -A
git commit -m'update nps score' || true
git push -u origin HEAD || true