Detect new functions #111
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: Detect new functions | |
on: | |
schedule: | |
- cron: 0 0 * * * | |
workflow_dispatch: | |
jobs: | |
detect-missing-funcs: | |
name: Check for new template functions | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
env: | |
GH_TOKEN: ${{ github.token }} | |
LYTFS_GITHUB_TOKEN: ${{ github.token }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: 1.22 | |
- run: go install github.com/jo3-l/yagfuncdata/cmd/lytfs@latest | |
- name: Generate diff against lytfs and create issue if needed | |
run: | | |
new_func_diff=$(python3 cmd/lytfs-diff.py) | |
existing_issue=$(gh issue list --label new-funcs --state open --json number -q '.[0].number') | |
if [ -n "$new_func_diff" ]; then | |
issue_body=$( | |
cat << EOF | |
## ⚠️ Bundled function definitions are outdated | |
The following functions need to be added: | |
\`\`\`diff | |
$new_func_diff | |
\`\`\` | |
This check is run automatically every day at 00:00 UTC. Go to the [Actions tab][new-funcs-workflow] to manually trigger an update. | |
[new-funcs-workflow]: https://github.com/jo3-l/yag-template-lsp/actions/workflows/new-funcs.yml | |
_Last updated at: $(date -u +"%Y-%m-%d %H:%M:%S UTC")_ | |
EOF | |
) | |
if [ -n "$existing_issue" ]; then | |
gh issue edit "$existing_issue" --body "$issue_body" | |
else | |
gh issue create --title "Bundled function definitions are outdated" --body "$issue_body" --label new-funcs --assignee jo3-l | |
fi | |
else | |
echo "no new functions" | |
if [ -n "$existing_issue" ]; then | |
gh issue close "$existing_issue" --comment "All new functions have been added." --reason completed | |
fi | |
fi |