Skip to content

UN-2686 ci: auto-release conflict-free bot SDK release PRs - #768

Merged
youssef-saber-3 merged 1 commit into
masterfrom
UN-2686-1795612837899-jira-to-pr
Nov 25, 2026
Merged

youssef-saber-3 merged 1 commit into
masterfrom
UN-2686-1795612837899-jira-to-pr

Conversation

@pipedrive-backoffice-pr

@pipedrive-backoffice-pr pipedrive-backoffice-pr Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Description

This PR rewrites .github/workflows/on-pd-bot-pr-opened.yml. With it, the bot's "Build N - version-X" release PRs are published to npm without anyone adding a label by hand. cicd_npm-publish.yml is not changed.

What the workflow does

  • Triggers: pull_request on master (labeled, synchronize, reopened, closed) and workflow_dispatch. The job runs only for PRs authored by pipedrive-github-actions-bot[bot]. The old pipedrive-bot actor check is removed. For labeled events, the label must be npm-version-*. This also means the workflow does not react to the npm-ready-for-publish label it adds itself. The existing guard against PRs that already have npm-ready-for-publish is kept.
  • Queue: each run finds the oldest open bot release PR on master (author is the bot, has an npm-version-* label) and works only on that one. Newer PRs wait. Because closed is a trigger, the next PR is picked up once the older one is merged or closed. Because synchronize and reopened are triggers, a PR is picked up again after someone fixes its CHANGELOG by hand. A non-cancelling concurrency group stops two runs from labeling PRs at the same time. Evaluating the oldest PR on every run means a dropped pending run cannot leave the queue stuck. If the oldest PR already has npm-ready-for-publish, the run does nothing because publishing is already in progress.
  • Conflict check: the workflow polls the PR API mergeable field while it is null (up to about 2 minutes). If mergeable == false or mergeable_state == dirty, the PR is not labeled. Instead, a Slack alert with the PR link and title is sent. The alert is sent only when the event is about the oldest PR itself, or on closed / manual runs, so pushes to newer PRs don't repeat it. If mergeability is still unknown after polling, the job fails and does not label the PR.
  • Release: when the PR is conflict-free, the workflow checks out the PR head and runs npm ci --ignore-scripts and npx changelog-updater --check. It then adds npm-ready-for-publish with a GitHub App installation token from actions/create-github-app-token@v3. This is the same App the reusable npm publish workflow already uses in this repo. Events created by an App token trigger other workflows, so cicd_npm-publish.yml then publishes and merges the PR. Events created with GITHUB_TOKEN would not.
  • Clean-up: checkout is updated from v3 to v4. setup-node now uses node-version-file: .nvmrc instead of the deprecated ::set-output. The default token gets minimal read permissions. The approval step is removed because publishing doesn't need it.

Needs action after merge / before relying on it

  1. Re-enable the workflow. It is disabled in the repository's Actions settings, and a PR cannot change that. A repo admin needs to enable it.
  2. Slack token. The alert step uses slackapi/slack-github-action@v2 and needs a bot token secret that can post to the alert channel. Confirm the secret exists in this repo and rename it in the workflow if needed.
  3. App token. The App credentials are assumed to be available, because the reusable publish workflow already requires them in this repo. The App needs permission to add labels to pull requests on this repo.

Known limitation: if the publish run fails after labeling, the oldest PR keeps npm-ready-for-publish and the queue stops at it until someone deals with it. This is intentional, so a failed release is never silently skipped.

Type of PR?

  • Maintenance

Manual testing

  • Ran actionlint. It passes, apart from one false positive: its bundled metadata is stale and doesn't know the client-id input. I checked the upstream actions/create-github-app-token@v3 action.yml, and it defines client-id.
  • Ran the queue jq filter against the live client-nodejs API (read-only). It matches Build 364 - version-major #767 (bot author plus npm-version-major). No bot PRs are open right now, so a run today would exit with nothing to do.
  • End-to-end check: the next real bot release PR after merge and re-enable should appear on npm with its CHANGELOG section, with no manual step.

Automated tests added?

  • N/A (CI workflow change)

Rewrite on-pd-bot-pr-opened workflow to add the npm-ready-for-publish
label (via GitHub App token) to the oldest conflict-free SDK release PR
opened by pipedrive-github-actions-bot, and alert Slack on conflicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pipedrive-backoffice-pr

Copy link
Copy Markdown
Author

Compliance check

Run: 45622601495

✅ Compliance report

Compliance Check: Passed

Scope: branch UN-2686-1795612837899-jira-to-pr vs origin/master (checked out). 1 file changed: .github/workflows/on-pd-bot-pr-opened.yml
Templates: #297 PR REVIEW VERSION: Security by Design Checklist v1 (151 prompt rules), #503 PR Release Checklist v1 (10 prompt rules)
Results: ℹ️ 1 notice, ✅ 1 passed, ➖ 159 N/A

Failed rules

All compliance rules passed.

Pre-existing failures

  • ⚠️ ℹ️ Unable to update deal's custom field because of wrong fieldname normalization #297 / 5111 TLS + Referrer-Policy when not on PD infra (Pre-existing). This rule applies because the repo has no .deploy/helm/Chart.yaml, and no global Referrer-Policy header is set. That is how the repo already was, and the PR does not change it. The repo is the pipedrive npm client library (repository.json type library) and runs no HTTP server, so the rule has nothing it can act on here.

Template #297: Security by Design Checklist v1

Notices

  • ℹ️ 5111 TLS + Referrer-Policy when not on PD infra (Pre-existing). See above.
Passed rules (1)
  • ✅ 4955 Secrets not in code/config. No hard-coded secrets were added. Credentials are referenced only through secrets.*, vars.* and github.token.
N/A rules (149)
  • ➖ Repo is a library, not a service: 4981
  • ➖ No backend, frontend, route, DB, auth, OAuth, GraphQL, Docker, Helm, dependency or file-I/O changes. The diff only touches a GitHub Actions workflow: all other rules in the template (148 rules)

Template #503: PR Release Checklist v1

N/A rules (10)
  • ➖ No migration, route, job, worker or outbound HTTP client changes in TS/JS source, and the repo is a library, not a service: 7315, 7316, 7317, 7318, 7319, 7320, 7321, 7322, 7323
  • ➖ No new process.env or diplomat lookups in non-test source (CI workflow files are excluded): 7324

Evaluated by compliance-engine:compliance-check. Templates: #297, #503

@pipedrive-backoffice-pr

Copy link
Copy Markdown
Author

Jira relevance check (UN-2686): Relevant

The PR changes one file, .github/workflows/on-pd-bot-pr-opened.yml, which is the workflow the ticket asks to fix. I found no unrelated changes. cicd_npm-publish.yml and other cicd_* files are not touched, so a @pipedrive/devops-tooling review is not needed for CODEOWNERS.

How the diff matches the acceptance criteria

Ticket requirement In the PR
Match pipedrive-github-actions-bot[bot] instead of pipedrive-bot ✅ Filters on github.event.pull_request.user.login == 'pipedrive-github-actions-bot[bot]'. The old pipedrive-bot check is removed.
Add npm-ready-for-publish with an App token, not GITHUB_TOKEN ✅ Uses actions/create-github-app-token@v3 with the PD_PUBLIC_GHA_BOT_* credentials, then runs gh pr edit --add-label with that token.
Never auto-release PRs with conflicts; alert Slack C03VBUTCHHU ✅ Polls mergeable while it is null. false/dirty sends a Slack message with the PR link and title via slackapi/slack-github-action@v2.
Oldest PR first; newer PRs re-evaluated later ✅ Picks the lowest-numbered open bot PR with an npm-version-* label. Adds synchronize, reopened, closed and workflow_dispatch triggers, plus a concurrency group.
Keep the guard against PRs that already have npm-ready-for-publish ✅ Kept in the job if, and checked again for the oldest PR.
Keep changelog-updater --check; optional modernisation ✅ Kept. Moves to checkout v4, uses node-version-file instead of ::set-output, and runs npm ci.
Approval step optional ✅ Removed, which the ticket allows.

Points to check (not blocking for relevance)

  • Secrets: confirm vars.PD_PUBLIC_GHA_BOT_CLIENT_ID, secrets.PD_PUBLIC_GHA_BOT_APPLICATION_PRIVATE_KEY_PEM and secrets.SLACK_BOT_TOKEN are available to this repo, and that the Slack bot is a member of #gravity-tribe-notifications. The step is named "Pipedrive GitHub Actions Bot Token" but uses the pipedrive-public-gha-bot credentials. Consider renaming it to avoid confusion.
  • Stalled queue: if cicd_npm-publish.yml fails and leaves npm-ready-for-publish on the oldest PR, the workflow does nothing on every later run, and nobody is alerted. Consider a Slack alert, or at least documenting this case.
  • Manual steps outside the PR: the workflow is still disabled_manually. It has to be re-enabled in GitHub after merge. Verification on npm also has to wait for the next real bot release PR. Please track both in the PR description or the ticket.

@youssef-saber-3
youssef-saber-3 marked this pull request as ready for review November 25, 2026 13:57
@youssef-saber-3
youssef-saber-3 merged commit 8ea8c80 into master Nov 25, 2026
1 check passed
@claude claude Bot mentioned this pull request Nov 25, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant