Last active
January 22, 2025 14:59
-
-
Save voxpelli/c8b6cde40ca1b2779afafcb55d1fbfdd to your computer and use it in GitHub Desktop.
GitHub Action for leasot CLI tool
This file contains hidden or 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: List Todos | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
pull_request: | |
branches: | |
- main | |
permissions: | |
contents: read | |
issues: write | |
jobs: | |
list-todos: | |
runs-on: 'ubuntu-latest' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
show-progress: false | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' | |
registry-url: 'https://registry.npmjs.org' | |
- run: npm ci --ignore-scripts --no-fund --no-audit | |
- name: Generate job summary | |
run: npx --yes leasot index.js 'lib/**/*.js' --exit-nicely --reporter markdown | sed -e 's|][(]|](/${{ github.repository }}/blob/${{ github.sha }}/|' >> $GITHUB_STEP_SUMMARY | |
# If on main branch, then create / update the reference issue | |
- if: github.ref_name == 'main' | |
id: current-issue | |
name: Look up existing issue | |
run: echo "number=$(gh issue list --json number,title -q 'map(select(.title=="Current TODO comments")) | .[0].number')" >> $GITHUB_OUTPUT | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Edit issue | |
if: github.ref_name == 'main' && steps.current-issue.outputs.number | |
run: > | |
npm run --silent list-todos-md | | |
sed -e 's|][(]|](/${{ github.repository }}/blob/${{ github.sha }}/|' | | |
gh issue edit ${{ steps.current-issue.outputs.number }} --body-file - | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create issue | |
if: github.ref_name == 'main' && !steps.current-issue.outputs.number | |
run: > | |
npm run --silent list-todos-md | | |
sed -e 's|][(]|](/${{ github.repository }}/blob/${{ github.sha }}/|' | | |
gh issue create --title "Current TODO comments" --body-file - | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment