|
| 1 | +name: Deprecated connector |
| 2 | + |
| 3 | +# - Labels PRs that touch deprecated destination connectors (actions/labeler). |
| 4 | +# - On bug reports, applies the `deprecated` label only when the selected |
| 5 | +# destination connector (issue-form dropdown) is a deprecated one. |
| 6 | +# - Posts a single informational notice on any issue/PR carrying the |
| 7 | +# `deprecated` label. It never closes the issue or PR. |
| 8 | +# |
| 9 | +# NOTE: the `deprecated` label must be created once in the repository settings |
| 10 | +# (Settings -> Labels) — labels are not defined in this repo. |
| 11 | + |
| 12 | +on: |
| 13 | + pull_request_target: |
| 14 | + types: [opened, synchronize, reopened] |
| 15 | + pull_request: |
| 16 | + types: [labeled] |
| 17 | + issues: |
| 18 | + types: [opened, edited, labeled] |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: read |
| 22 | + |
| 23 | +jobs: |
| 24 | + # Apply path-based labels (incl. `deprecated`) to PRs per .github/labeler.yml. |
| 25 | + label: |
| 26 | + if: github.event_name == 'pull_request_target' |
| 27 | + runs-on: ubuntu-latest |
| 28 | + permissions: |
| 29 | + contents: read |
| 30 | + pull-requests: write |
| 31 | + steps: |
| 32 | + - uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0 |
| 33 | + with: |
| 34 | + sync-labels: false |
| 35 | + |
| 36 | + # On a new/edited bug report, apply `deprecated` only when the chosen |
| 37 | + # destination connector (issue-form dropdown) is a deprecated one. Issues |
| 38 | + # that select an actively-maintained destination are left untouched. |
| 39 | + triage-issue: |
| 40 | + if: github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'edited') |
| 41 | + runs-on: ubuntu-latest |
| 42 | + permissions: |
| 43 | + issues: write |
| 44 | + steps: |
| 45 | + - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 46 | + with: |
| 47 | + script: | |
| 48 | + const issue = context.payload.issue; |
| 49 | + const body = issue.body || ''; |
| 50 | + // Extract the "Destination connector" dropdown value from the form body. |
| 51 | + const match = body.match(/###\s*Destination connector\s*\r?\n+\s*(.+)/); |
| 52 | + const selection = match ? match[1].trim() : ''; |
| 53 | + const deprecated = new Set([ |
| 54 | + 'Snowflake', 'BigQuery', 'ElasticSearch', 'Kafka', 'Redpanda', |
| 55 | + 'Confluent', 'Azure Event Hubs', 'Google Pub/Sub', |
| 56 | + ]); |
| 57 | + if (!deprecated.has(selection)) { |
| 58 | + core.info(`Destination "${selection || '(none)'}" is not a deprecated connector; not labeling.`); |
| 59 | + return; |
| 60 | + } |
| 61 | + if ((issue.labels || []).some((l) => (l.name || l) === 'deprecated')) { |
| 62 | + core.info('Issue already labeled deprecated.'); |
| 63 | + return; |
| 64 | + } |
| 65 | + await github.rest.issues.addLabels({ |
| 66 | + owner: context.repo.owner, |
| 67 | + repo: context.repo.repo, |
| 68 | + issue_number: issue.number, |
| 69 | + labels: ['deprecated'], |
| 70 | + }); |
| 71 | + core.info(`Labeled issue #${issue.number} deprecated (destination: ${selection}).`); |
| 72 | +
|
| 73 | + # Post a one-time notice when the `deprecated` label is present on an issue/PR. |
| 74 | + # Depends on the prior jobs so it observes labels they applied within this same |
| 75 | + # run (a GITHUB_TOKEN label write does not itself emit a `labeled` event). |
| 76 | + # `if: always()` keeps it running when an upstream job is skipped. |
| 77 | + notice: |
| 78 | + needs: [label, triage-issue] |
| 79 | + if: always() |
| 80 | + runs-on: ubuntu-latest |
| 81 | + permissions: |
| 82 | + issues: write |
| 83 | + pull-requests: write |
| 84 | + steps: |
| 85 | + - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 86 | + with: |
| 87 | + script: | |
| 88 | + const marker = '<!-- deprecated-connector-notice -->'; |
| 89 | + const number = |
| 90 | + context.eventName === 'issues' |
| 91 | + ? context.payload.issue?.number |
| 92 | + : context.payload.pull_request?.number; |
| 93 | + if (!number) { |
| 94 | + core.info('No issue/PR number in payload; nothing to do.'); |
| 95 | + return; |
| 96 | + } |
| 97 | +
|
| 98 | + // Re-fetch labels so we observe any applied by the label/triage jobs |
| 99 | + // earlier in this run (rather than the stale event payload). |
| 100 | + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ |
| 101 | + owner: context.repo.owner, |
| 102 | + repo: context.repo.repo, |
| 103 | + issue_number: number, |
| 104 | + }); |
| 105 | + if (!labels.some((l) => l.name === 'deprecated')) { |
| 106 | + core.info('No deprecated label present; nothing to do.'); |
| 107 | + return; |
| 108 | + } |
| 109 | +
|
| 110 | + // Guard against duplicate comments using the hidden marker. |
| 111 | + const comments = await github.paginate(github.rest.issues.listComments, { |
| 112 | + owner: context.repo.owner, |
| 113 | + repo: context.repo.repo, |
| 114 | + issue_number: number, |
| 115 | + }); |
| 116 | + if (comments.some((c) => c.body && c.body.includes(marker))) { |
| 117 | + core.info('Deprecated-connector notice already posted; skipping.'); |
| 118 | + return; |
| 119 | + } |
| 120 | +
|
| 121 | + const body = [ |
| 122 | + marker, |
| 123 | + '### ⚠️ Deprecated destination connector', |
| 124 | + '', |
| 125 | + 'This issue or pull request relates to a **deprecated** destination connector ' + |
| 126 | + '(Snowflake, BigQuery, ElasticSearch, Kafka, Redpanda, Confluent, Azure Event Hubs, or Google Pub/Sub).', |
| 127 | + '', |
| 128 | + 'These destinations are **no longer actively maintained**, but remain functional. ' + |
| 129 | + 'We are unlikely to prioritize new work here.', |
| 130 | + '', |
| 131 | + '> Note: BigQuery is deprecated **only as a destination** — it remains a supported source.', |
| 132 | + '', |
| 133 | + 'If you depend on one of these connectors, we recommend:', |
| 134 | + '', |
| 135 | + '- **Pin** to a known-good PeerDB version so behavior stays stable.', |
| 136 | + '- **Fork** the repository if you need to carry your own changes.', |
| 137 | + '', |
| 138 | + 'See the [deprecated connectors documentation](https://github.com/PeerDB-io/peerdb/blob/main/docs/deprecated-connectors.md) for details and migration guidance.', |
| 139 | + ].join('\n'); |
| 140 | +
|
| 141 | + await github.rest.issues.createComment({ |
| 142 | + owner: context.repo.owner, |
| 143 | + repo: context.repo.repo, |
| 144 | + issue_number: number, |
| 145 | + body, |
| 146 | + }); |
| 147 | + core.info(`Posted deprecated-connector notice on #${number}.`); |
0 commit comments