|
| 1 | +name: Check DataWeave version |
| 2 | + |
| 3 | +# Watches the LIVE MuleSoft docs for a newer DataWeave version (or newly added |
| 4 | +# dw::Core functions) than the cheatsheet records, and opens/updates ONE tracking |
| 5 | +# issue when the article is out of date. It NEVER edits the article — the verbatim |
| 6 | +# sync is a human/`dataweave-reference-syncer` job (see CLAUDE.md). |
| 7 | +# |
| 8 | +# Trigger: weekly cron + manual. (MuleSoft publishes no RSS feed for releases, and |
| 9 | +# the version source is external to this repo, so a schedule is the right shape — |
| 10 | +# `push` would mostly re-check after unrelated commits. Run "Run workflow" anytime.) |
| 11 | + |
| 12 | +on: |
| 13 | + schedule: |
| 14 | + - cron: '0 13 * * 1' # every Monday 13:00 UTC |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + issues: write |
| 20 | + |
| 21 | +concurrency: |
| 22 | + group: check-dataweave-version |
| 23 | + cancel-in-progress: false |
| 24 | + |
| 25 | +jobs: |
| 26 | + check: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: Checkout |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Set up Node |
| 33 | + uses: actions/setup-node@v4 |
| 34 | + with: |
| 35 | + node-version: 20 |
| 36 | + |
| 37 | + - name: Check cheatsheet vs. live DataWeave docs |
| 38 | + id: check |
| 39 | + run: node scripts/check-dataweave-version.mjs |
| 40 | + |
| 41 | + - name: Open / update tracking issue |
| 42 | + if: steps.check.outputs.outdated == 'true' |
| 43 | + uses: actions/github-script@v7 |
| 44 | + env: |
| 45 | + ISSUE_TITLE: ${{ steps.check.outputs.issue_title }} |
| 46 | + ISSUE_BODY: ${{ steps.check.outputs.issue_body }} |
| 47 | + LIVE_VERSION: ${{ steps.check.outputs.live_version }} |
| 48 | + with: |
| 49 | + script: | |
| 50 | + const { ISSUE_TITLE, ISSUE_BODY, LIVE_VERSION } = process.env; |
| 51 | + const label = 'dataweave-version'; |
| 52 | +
|
| 53 | + // Ensure the label exists (ignore "already exists"). |
| 54 | + try { |
| 55 | + await github.rest.issues.createLabel({ |
| 56 | + owner: context.repo.owner, repo: context.repo.repo, |
| 57 | + name: label, color: '0e8a16', |
| 58 | + description: 'DataWeave cheatsheet out of date vs. the live docs', |
| 59 | + }); |
| 60 | + } catch (e) { if (e.status !== 422) throw e; } |
| 61 | +
|
| 62 | + // Reuse the existing open tracking issue if there is one (don't spam a |
| 63 | + // new issue every week — update the body and ping instead). |
| 64 | + const existing = await github.paginate(github.rest.issues.listForRepo, { |
| 65 | + owner: context.repo.owner, repo: context.repo.repo, |
| 66 | + state: 'open', labels: label, per_page: 100, |
| 67 | + }); |
| 68 | +
|
| 69 | + if (existing.length) { |
| 70 | + const issue = existing[0]; |
| 71 | + await github.rest.issues.update({ |
| 72 | + owner: context.repo.owner, repo: context.repo.repo, |
| 73 | + issue_number: issue.number, title: ISSUE_TITLE, body: ISSUE_BODY, |
| 74 | + }); |
| 75 | + await github.rest.issues.createComment({ |
| 76 | + owner: context.repo.owner, repo: context.repo.repo, |
| 77 | + issue_number: issue.number, |
| 78 | + body: `🔁 Re-checked: docs \`latest\` is at **${LIVE_VERSION}**. Details updated above.`, |
| 79 | + }); |
| 80 | + core.info(`Updated existing issue #${issue.number}`); |
| 81 | + } else { |
| 82 | + const created = await github.rest.issues.create({ |
| 83 | + owner: context.repo.owner, repo: context.repo.repo, |
| 84 | + title: ISSUE_TITLE, body: ISSUE_BODY, labels: [label], |
| 85 | + }); |
| 86 | + core.info(`Opened issue #${created.data.number}`); |
| 87 | + } |
0 commit comments