googleapis / release-please-action

automated releases based on conventional commits
Apache License 2.0
1.66k stars 206 forks source link

Infinite Loop with Release-please action #1028

Open dan-connektica opened 1 month ago

dan-connektica commented 1 month ago

We are running into an issue where an infinite loop is being triggered for one of our repositories that uses the release please github action. We use the github action on multiple repos, with a similar configuration, but only have this issue on a single repo, and it started yesterday without any modifications to the workflow files or release-please configuration.

After merging a PR to our master branch, release please was triggered to update the Pull request release-please--branches--master with the new commit. However, this triggers an additional release-please job to start. Normally we see a message like this, indicating that the pull request is already up to date and there is no update needed:

...
✔ Looking for open release pull requests
✔ found 1 open release pull requests.
✔ Looking for snoozed release pull requests
✔ found 0 snoozed release pull requests.
✔ PR https://github.com/example-organization/example-repo/pull/851 remained the same

However for one repo, it triggers an additional update to the pull request, which re-triggers the release-please action:

✔ Looking for open release pull requests
✔ found 1 open release pull requests.
✔ Looking for snoozed release pull requests
✔ found 0 snoozed release pull requests.
❯ Fetching backend/CHANGELOG.md from branch master
❯ Fetching .release-please-manifest.json from branch master
❯ Fetching workers/transmitter-worker/CHANGELOG.md from branch master
❯ Fetching workers/transmitter-worker/setup.cfg from branch master
⚠ file workers/transmitter-worker/setup.cfg did not exist
⚠ file workers/transmitter-worker/setup.py did not exist
❯ Fetching workers/transmitter-worker/setup.py from branch master
❯ Fetching workers/transmitter-worker/pyproject.toml from branch master
⚠ file workers/transmitter-worker/transmitter-worker/__init__.py did not exist
❯ Fetching workers/transmitter-worker/transmitter-worker/__init__.py from branch master
⚠ file workers/transmitter-worker/src/transmitter-worker/__init__.py did not exist
❯ Fetching workers/transmitter-worker/src/transmitter-worker/__init__.py from branch master
❯ Fetching workers/transmitter-worker/loft_transmitter_worker/__init__.py from branch master
❯ Fetching workers/transmitter-worker/src/loft_transmitter_worker/__init__.py from branch master
⚠ file workers/transmitter-worker/src/loft_transmitter_worker/__init__.py did not exist
⚠ file changelog.json did not exist
❯ Fetching changelog.json from branch master
✔ Starting GitHub PR workflow...
✔ Successfully found branch HEAD sha "29925cef9e3a3[82](https://github.com/connektica/test_station/actions/runs/10634469395/job/29481855498#step:2:83)5a7a5a82466b8bde27121934e".
✔ Skipping branch creation step...
✔ Got the latest commit tree
✔ Successfully created a tree with the desired changes with SHA aa5d33109016dc8e53aaa3b48efa0617e137c3c9
✔ Successfully created commit. See commit at https://api.github.com/repos/connektica/test_station/git/commits/56beabd17cf9fe0b2c34ed3652522765c27e2d99
✔ Updating reference heads/release-please--branches--master to 56beabd17cf9fe0b2c34ed3652522765c27e2d99
✔ Successfully updated reference release-please--branches--master to 56beabd17cf9fe0b2c34ed3652522765c27e2d99
✔ Found existing pull request for reference connektica:release-please--branches--master. Skipping creating a new pull request.
✔ Successfully opened pull request: 958.

The commit hash is different every time, and it triggers over and over until we disable the workflow. Our other repositories with release-please do not have this issue.

Below is the release-please.yaml workflow that we are using, slightly modified to redact specific information:

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master
    paths-ignore:
      - infra/**
      - tenants/**

permissions:
  id-token: write
  contents: write
  pull-requests: write

name: release-please

jobs:
  release_please:
    runs-on: ubuntu-latest
    outputs:
      releases_created: ${{ steps.release.outputs.releases_created }}
      test-station: ${{ steps.release.outputs['backend--release_created'] }}
      cloud-worker: ${{ steps.release.outputs['workers/cloud-worker--release_created'] }}
      transmitter-worker: ${{ steps.release.outputs['workers/transmitter-worker--release_created'] }}
    steps:
      - uses: googleapis/release-please-action@v4
        id: release
        with:
          # this assumes that you have created a personal access token
          # (PAT) and configured it as a GitHub action secret named
          # `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important).
          token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
          config-file: release-please-config.json
          manifest-file: .release-please-manifest.json
      - name: Check Output
        run: |
          cat << EOF
          ${{ toJSON(steps.release.outputs) }}
          EOF

...

.release-please-manifest.json

{
  "backend": "2.24.0",
  "workers/cloud-worker": "2.19.0",
  "workers/transmitter-worker": "2.19.0"
}

release-please-config.json:

{
  "packages": {
    "backend": {
      "bootstrap-sha": "adf1e27d71de0b2f19fae293b167cfad1602a057",
      "package-name": "station-api",
      "release-type": "go",
      "tag-separator": "/",
      "changelog-path": "CHANGELOG.md",
      "bump-minor-pre-major": true,
      "bump-patch-for-minor-pre-major": false,
      "draft": false,
      "prerelease": false
    },
    "workers/cloud-worker": {
      "bootstrap-sha": "adf1e27d71de0b2f19fae293b167cfad1602a057",
      "package-name": "cloud-worker",
      "release-type": "python",
      "tag-separator": "/",
      "changelog-path": "CHANGELOG.md",
      "bump-minor-pre-major": true,
      "bump-patch-for-minor-pre-major": false,
      "draft": false,
      "prerelease": false
    },
    "workers/transmitter-worker": {
      "bootstrap-sha": "adf1e27d71de0b2f19fae293b167cfad1602a057",
      "package-name": "transmitter-worker",
      "release-type": "python",
      "tag-separator": "/",
      "changelog-path": "CHANGELOG.md",
      "bump-minor-pre-major": true,
      "bump-patch-for-minor-pre-major": false,
      "draft": false,
      "prerelease": false
    }
  },
  "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}

Environment details

Steps to reproduce

We do not know how to reproduce this, but everything we've tried results in the same issue for one particular repository. Other repos using basically the same workflow config do not experience this issue.

dan-connektica commented 1 month ago

We applied a workaround for now to prevent release-please running on the release branch pull request:

...
jobs:
  release_please:
    if: github.head_ref != 'release-please--branches--master'
    runs-on: ubuntu-latest
    outputs:
...