Update pattern library #5
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: Update pattern library | |
| on: | |
| schedule: | |
| - cron: "0 9 * * 1" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| concurrency: | |
| group: update-pattern-library | |
| cancel-in-progress: false | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Scan active workflows | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} | |
| run: scripts/scan.sh --active-only --run-history | |
| - name: Generate patterns | |
| run: python3 scripts/generate-patterns.py | |
| - name: Create or update pull request | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| BRANCH: automation/update-patterns | |
| PR_TITLE: "📊 Pattern library update" | |
| run: | | |
| if git diff --quiet -- patterns/; then | |
| echo "patterns/ is unchanged; no pull request update is needed." | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git fetch origin "refs/heads/$BRANCH:refs/remotes/origin/$BRANCH" || true | |
| git switch -C "$BRANCH" "$GITHUB_SHA" | |
| git add patterns/ | |
| git commit -m "Update pattern library" | |
| git push --force-with-lease origin "HEAD:$BRANCH" | |
| body="Automated weekly refresh of \`patterns/\` from active agentic workflow data." | |
| pr_number="$(gh pr list --state open --head "$BRANCH" --json number --jq '.[0].number // empty')" | |
| if [ -n "$pr_number" ]; then | |
| gh pr edit "$pr_number" --title "$PR_TITLE" --body "$body" | |
| else | |
| gh pr create --base "${{ github.event.repository.default_branch }}" --head "$BRANCH" --title "$PR_TITLE" --body "$body" | |
| fi |