Skip to content

feat: add process-dependabot-reusable workflow (Bash-based alternative)#419

Merged
ppkarwasz merged 31 commits into
mainfrom
feat/dependabot-add-changelog2
May 2, 2026
Merged

feat: add process-dependabot-reusable workflow (Bash-based alternative)#419
ppkarwasz merged 31 commits into
mainfrom
feat/dependabot-add-changelog2

Conversation

@ppkarwasz

@ppkarwasz ppkarwasz commented Jun 22, 2025

Copy link
Copy Markdown
Member

This PR introduces a reusable GitHub Actions workflow, process-dependabot-reusable, designed to streamline the handling of Dependabot pull requests across repositories — implemented entirely with shell scripts.

This serves as a Bash-based alternative to #418, which uses TypeScript.

🔄 Key Differences from #418

  • Trigger: Runs on pull_request_target (not push), which is required by the dependabot/fetch-metadata action.

  • Implementation: Written using standard POSIX tools with a few dependencies:

    • bash – some Bash-specific constructs are used
    • jq – for processing JSON output from dependabot/fetch-metadata
    • xmlstarlet – for parsing pom.xml and generating a changelog XML file
    • git – to commit and push any changes
    • gh – to enable "auto-merge" on the pull request

This approach avoids the Node.js/TypeScript toolchain and relies only on standard CLI tools commonly available in CI environments.

Updated version

The updated version of this PR splits the workflow into two parts:

  • Unprivileged workflow (analyze-dependabot-reusable):
    Runs on pull_request with no permissions. It analyzes Dependabot PRs and generates metadata safely.

  • Privileged workflow (process-dependabot-reusable):
    Uses the metadata from the unprivileged step to generate changelog files and enable the "auto-merge" option. Requires access to our GPG key and Personal Access Token.

…ive)

This PR introduces a **reusable GitHub Actions workflow**, `process-dependabot-reusable`, designed to streamline the handling of Dependabot pull requests across repositories — implemented entirely with **shell scripts**.

This serves as a Bash-based alternative to #418, which uses TypeScript.

### 🔄 Key Differences from #418

* **Trigger**: Runs on `pull_request_target` (not `push`), which is required by the `dependabot/fetch-metadata` action.
* **Implementation**: Written using **standard POSIX tools** with a few dependencies:

  * **`bash`** – some Bash-specific constructs are used
  * **`jq`** – for processing JSON output from `dependabot/fetch-metadata`
  * **`xmlstarlet`** – for parsing `pom.xml` and generating a changelog XML file
  * **`git`** – to commit and push any changes
  * **`gh`** – to enable "auto-merge" on the pull request

This approach avoids the Node.js/TypeScript toolchain and relies only on standard CLI tools commonly available in CI environments.
@ppkarwasz
ppkarwasz requested review from Copilot and vy June 22, 2025 09:31

This comment was marked as outdated.

@ppkarwasz

ppkarwasz commented Jun 22, 2025

Copy link
Copy Markdown
Member Author

After running some tests, I identified the following limitations with this workflow stemming from the use of dependabot/fetch-metadata:

This change splits the Dependabot automation into two reusable workflows:

* **Unprivileged workflow** (`analyze-dependabot-reusable`):
  Runs on `pull_request` with no permissions. It analyzes Dependabot PRs and generates metadata safely.

* **Privileged workflow** (`process-dependabot-reusable`):
  Uses the metadata from the unprivileged step to generate changelog files and enable the "auto-merge" option. Requires access to our GPG key and Personal Access Token.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new Bash-based reusable GitHub Actions workflow for processing Dependabot pull requests and a complementary workflow for analyzing them.

  • Introduces the process-dependabot-reusable workflow that generates changelog entries and enables auto-merge.
  • Splits the workflow into two parts (analyze and process) and updates related documentation and examples.
  • Adds an XML changelog entry and updates workflow examples to reflect the new structure.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/site/antora/modules/ROOT/pages/workflows.adoc Updates documentation to include examples and explanations for the new workflows.
src/site/antora/modules/ROOT/examples/process-dependabot.yaml Provides an example usage of the new process workflow.
src/site/antora/modules/ROOT/examples/analyze-dependabot.yaml Provides an example usage of the new analyze workflow.
src/changelog/.12.x.x/add-deploy-profile.xml Adds a changelog entry documenting the addition of the new workflow.
.github/workflows/process-dependabot-reusable.yaml Implements the workflow that generates changelog entries and enables auto-merge for Dependabot PRs.
.github/workflows/analyze-dependabot-reusable.yaml Implements the workflow to analyze Dependabot PRs and prepare metadata for processing.
Comments suppressed due to low confidence (2)

.github/workflows/process-dependabot-reusable.yaml:168

  • Consider using the PR_URL extracted earlier from the fetched metadata (set in GITHUB_ENV) instead of relying on github.event.pull_request.html_url to ensure consistency across the workflow.
          PR_URL: ${{ github.event.pull_request.html_url }}

.github/workflows/process-dependabot-reusable.yaml:104

  • [nitpick] The indentation of the 'exit 1' statement (line 106) is inconsistent with the block structure; aligning it with the preceding echo statement will improve readability.
          if [[ ! $revision =~ ^[0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT)?$ ]]; then

Comment thread .github/workflows/process-dependabot-reusable.yaml Outdated
Comment thread .github/workflows/analyze-dependabot-reusable.yaml Outdated
Comment thread .github/workflows/analyze-dependabot-reusable.yaml Outdated
Comment thread .github/workflows/analyze-dependabot-reusable.yaml Outdated
Comment thread .github/workflows/analyze-dependabot-reusable.yaml Outdated
Comment thread .github/workflows/analyze-dependabot-reusable.yaml Outdated
Comment thread .github/workflows/process-dependabot-reusable.yaml Outdated
Comment thread .github/workflows/process-dependabot-reusable.yaml Outdated
Comment thread .github/workflows/process-dependabot-reusable.yaml Outdated
Comment thread src/site/antora/modules/ROOT/examples/analyze-dependabot.yaml Outdated
Comment thread src/site/antora/modules/ROOT/examples/process-dependabot.yaml Outdated
ppkarwasz added a commit to ppkarwasz/infrastructure-actions that referenced this pull request Oct 26, 2025
…etadata`

This PR allows the usage of the `ppkarwasz/fetch-metadata` GitHub Action as an alternative to `dependabot/fetch-metadata` in ASF repositories.

The `ppkarwasz/fetch-metadata` action is a personal improvement of the original `dependabot/fetch-metadata`, adding support for grouped Dependabot pull requests, a feature that is currently missing from the upstream action. The implementation has already been reviewed and approved by the Dependabot team (see dependabot/fetch-metadata#632), but the upstream project has been inactive for several months, likely due to reduced maintenance capacity at GitHub. This has prevented the improvement from being merged and released.

### Why this change is needed

In Apache Logging Services, every pull request must include a changelog entry. Previously, under CTR, we used a workflow that automatically added the changelog entry and merged the PR.

Since switching to RTC, this automation can no longer complete the merge step, resulting in repositories accumulating unmerged Dependabot PRs that must be:

* manually reviewed,
* updated with an empty commit to re-trigger required status checks,
* and merged by hand.

We already have an improved workflow in place (see apache/logging-parent#419) that provides:

* **Security enhancements** through separation of privileged and unprivileged workflows
  (`ppkarwasz/fetch-metadata` is used only in the unprivileged workflow),
* **Automatic merge using `auto-merge` instead of manual merging**, and
* **Support for grouped Dependabot PRs** (reducing noise to ~1 PR per repository per month).

The final item, grouped PR support, requires the `ppkarwasz/fetch-metadata` action.
@vy

vy commented Apr 15, 2026

Copy link
Copy Markdown
Member

Can you keep this PR on hold, please? I will suggest an alternative in a day or two.

@ppkarwasz

Copy link
Copy Markdown
Member Author

Sure, happy to wait a bit, though I'll note this PR has been open since June last year, mostly blocked on the dependabot/fetch-metadata side. Now that a new release finally landed on March 26th, I took the opportunity to bring it back in shape and strip it down to the bare essentials: no GPG signing, no unnecessary inputs or dependencies. I think it's about as simple as it gets at this point.

PR ppkarwasz/logging-log4j2#606 tests this in practice if you want to see how it behaves end-to-end.

I'm genuinely happy to look at alternative proposals, but one heads-up: please don't suggest collapsing this into a single pull_request_target workflow just to save a step or two. Even setting aside whether it'd be safe in this specific case, pull_request_target is a hard no under the ASF GitHub Actions policy: https://infra.apache.org/github-actions-policy.html

Getting an exception through INFRA would create way more churn than the two-workflow split is worth. If the policy ever tightens up around workflow_run too (as it should), we can revisit, but for now, the split is both policy-compliant and the right call.

@vy

vy commented Apr 16, 2026

Copy link
Copy Markdown
Member

A Personal Access Token (PAT) with contents:write permission must be provided instead.

@ppkarwasz, would you mind explaining how do we do that, please? Do we create an INFRA ticket?

I'm genuinely happy to look at alternative proposals

I suggest adding a Groovy script to gha/v0 that maintainers can run using a Maven profile inherited from logging-parent and pass it a Dependabot PR URL. For instance:

./mvnw -P generate-dependabot-changelog https://github.com/apache/logging-parent/pull/X

This will

  1. Checkout to the associated PR branch
  2. Generate changelog entries

Consequently, the maintainer can review these changes, commit, and push them. Since the commits will be originating from a maintainer, the CI will run without any extra permissions, PAT tokens, etc.

@ppkarwasz

Copy link
Copy Markdown
Member Author

A Personal Access Token (PAT) with contents:write permission must be provided instead.

@ppkarwasz, would you mind explaining how do we do that, please? Do we create an INFRA ticket?

We can upload a secret via gh secret create. To test it, you can run:

gh secret list

on the main Log4j repository. There should be a TEST_SECRET I uploaded 7 months ago.

@ppkarwasz

Copy link
Copy Markdown
Member Author

I suggest adding a Groovy script to gha/v0 that maintainers can run using a Maven profile inherited from logging-parent and pass it a Dependabot PR URL. For instance:

./mvnw -P generate-dependabot-changelog https://github.com/apache/logging-parent/pull/X

On one side, I would like to generate changelogs manually, but on the other hand I don't want to do it, if the CI can.

I wouldn't be too much concerned about using a PAT: we use reusable workflows after all and all secrets must be passed by the caller explicitly. The only workflow with access to the PAT will be process-dependabot-reusable.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 11 comments.

Comments suppressed due to low confidence (1)

src/site/antora/modules/ROOT/examples/analyze-dependabot.yaml:24

  • The example sets permissions: { }, which results in a permissionless GITHUB_TOKEN. If the reusable analyze-dependabot workflow needs to call the GitHub API (via dependabot/fetch-metadata), the caller should grant minimal read permissions (e.g., pull-requests: read and contents: read).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/process-dependabot-reusable.yaml Outdated
Comment thread src/site/antora/modules/ROOT/examples/process-dependabot.yaml
Comment thread .github/workflows/analyze-dependabot-reusable.yaml Outdated
Comment thread .github/workflows/process-dependabot-reusable.yaml Outdated
Comment thread src/site/antora/modules/ROOT/pages/workflows.adoc
Comment thread .github/workflows/analyze-dependabot-reusable.yaml Outdated
Comment thread .github/workflows/analyze-dependabot-reusable.yaml Outdated
Comment thread .github/workflows/process-dependabot-reusable.yaml Outdated
Comment thread .github/workflows/process-dependabot-reusable.yaml Outdated
Comment thread .github/workflows/process-dependabot-reusable.yaml Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ppkarwasz

Copy link
Copy Markdown
Member Author

I haven't tested yet, but apparently converting a PR to draft and back triggers workflows.

@vy, do you have anything against this PR if we don't use a PAT, but tricks?

@vy

vy commented Apr 19, 2026

Copy link
Copy Markdown
Member

@vy, do you have anything against this PR if we don't use a PAT, but tricks?

@ppkarwasz, if we don't use a PAT, how will it work?

@ppkarwasz

Copy link
Copy Markdown
Member Author

You can for example:

  • Convert the PR to draft and back, or
  • Update the PR to the latest branch.

This changes:

- Moves reusable workflows to the `gha/v0` branch (#473).
- Creates Dependabot workflows for `logging-parent`.
ppkarwasz added a commit that referenced this pull request May 2, 2026
This changes moves the reusable workflows from #419 to `gha/v0` and leaves the documentation in `main`.
@ppkarwasz
ppkarwasz merged commit 2d294d4 into main May 2, 2026
7 checks passed
@ppkarwasz
ppkarwasz deleted the feat/dependabot-add-changelog2 branch May 2, 2026 19:36
ppkarwasz added a commit to apache/logging-log4j2 that referenced this pull request May 2, 2026
Wire up the reusable workflows from apache/logging-parent#419 to:

- Generate changelog entries for Dependabot PRs.
- Re-run build checks on the newly created commit.
- Enable auto-merge, which only merges once required checks pass and a maintainer approves.

Together, these allow merging Dependabot PRs in a single click.

Also add a concurrency setting to `build.yaml` and `codeql-analysis.yaml` so superseded PR commits stop consuming runners.
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.

3 participants