release-please-action: Labels are not being correctly applied to PR using `GITHUB_TOKEN`

version:

Run googleapis/release-please-action@v4
Running release-please version: 16.12.0

It seems like release-please thinks it is adding the label successfully, even though no labels are added.

I ran the action with debug log enabled, and at the end of the pr output, "labels":[] is empty, but reporting Successfully added labels autorelease: pending.

Snippet of debug log:

✔ Successfully opened pull request: 2.
✔ Successfully added labels autorelease: pending to issue: 2
##[debug]Node Action run completed with exit code 0
##[debug]Set output releases_created = false
##[debug]Set output paths_released = []
##[debug]Set output prs_created = true
##[debug]Set output pr = {"headBranchName":"release-please--branches--main","baseBranchName":"main","number":2,"title":"chore(main): release 1.0.0","body":":robot: I have created a release *beep* *boop*\n---\n\n\n## 1.0.0 (2025-01-14)\n\n\n### Bug Fixes\n\n* test release ([13765cf](https://github.com/syaghoubi00/actions-testing/commit/13765cf982996c53e86ac13e83115f7843c335ee))\n\n---\nThis PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).","files":[],"labels":[]}

Possibly related: #1072 - however, adding the repository-projects: read permission did not fix the issue.

config:

on:
  push:
    branches:
      - main

permissions:
  contents: write
  pull-requests: write
  repository-projects: read
name: release-please

jobs:
  release-please:
    runs-on: ubuntu-latest
    steps:
      - uses: googleapis/release-please-action@v4
        with:
          release-type: simple

It might be worth noting that this isn’t a problem when using a PAT instead of the GH token.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 16
  • Comments: 26

Most upvoted comments

I was able to correct this issue by creating labels first, using the cli. Once the labels exist, there appear to be no issues.

When I tried to add a label using gh cli, to the PR, it said the label did not exist. It seems that labels are not auto-creating when adding them to a PR.

I added this to all my newly created repos using release-please, to resolve the issue:

gh label create "autorelease: pending"
gh label create "autorelease: tagged"
gh label create "autorelease: snapshot"
gh label create "autorelease: published"

Using ghaction-github-labeler solved this issue for me as well. Adding sample configuration here for anyone stumbling across this:

# .github/labels.yml
- name: "autorelease: pending"
  color: "d73a4a"
  description: "Pending release"
- name: "autorelease: tagged"
  color: "d4c5f9"
  description: "Ready for release"
- name: "autorelease: snapshot"
  color: "d4c5f9"
  description: "Ready for release"
- name: "autorelease: published"
  color: "0e8a16"
  description: "Released"
# .github/workflows/labels.yml
name: github-labels

on:
  push:
    branches:
      - 'main'
    paths:
      - '.github/labels.yml'
      - '.github/workflows/labels.yml'
  pull_request:
    paths:
      - '.github/labels.yml'
      - '.github/workflows/labels.yml'

jobs:
  labeler:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      issues: write
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Run Labeler
        uses: crazy-max/ghaction-github-labeler@v5
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          skip-delete: true
          dry-run: ${{ github.event_name == 'pull_request' }}

Same here,

  - name: Add labels to the repository if not present
    env:
      GH_TOKEN: ${{ github.token }}
    run: |
      gh label create "autorelease: pending" || true
      gh label create "autorelease: tagged" || true
      gh label create "autorelease: snapshot" || true
      gh label create "autorelease: published" || true

I am using this in the pipeline for a temp fix.

I guess it’s a valid workaround by side manually creating then, but release-please explicitly states that they create these labels so it still is a bug, would you agree?

I think what is broken is what I’d term “autovivification” of labels.

Using the following:

curl -v --location --request POST 'https://api.github.com/repos/{owner}/{repo}/issues/{number}/labels' \
  --header 'Accept: application/vnd.github.v3+json' \
  --header 'Authorization: Bearer ${{ secrets.github_token }}' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "labels": ["nonexistent", "bug"]
  }'

The label bug exists, the label nonexistent does not. Only bug gets added to the issue/PR. An HTTP 200 response code is always returned.

I’m assuming previously any label that didn’t exist when adding it to an issue/PR would be automatically created/vivified.

I’ve tried the built in token and an app token, both only with write permission on pull requests and both only add labels that already exist.

someone tried with the permission issues: write?

Yes I even tried all different write permission, adding each one by one.

ok, so the prob is not the action cannot create the labels, it’s that it does not try to create it if it doesn’t exist (it seems)

someone tried with the permission issues: write?

Yes I even tried all different write permission, adding each one by one.

Seems to be GitHub that broke label creation permissions on the GITHUB_TOKEN, not really a release-please issue, see here for other people experiencing the same with other actions: https://github.com/orgs/community/discussions/149877#discussioncomment-11952379

@syaghoubi00

thats the part i tried successfully, i defined it as a job required before the release-please job:

https://github.com/sonderformat-llc/run-quickstart-e2e-test/blob/66fa6a481d5f40fd42ee7bb46c3d44a7296fccb8/.github/workflows/release.yaml#L18-L35

FYI i edited my earlier comment, i meant that i can create the labels manually with the gh label create command. sorry for the confusion

I think this is a wider GitHub issue, some behaviour which was previously relied on has changed.

We also use Renovate which should also be creating and adding labels to PRs but I notice it’s not creating them either, without any sort of error. Like release-please, this used to work.

FYI I’m using an App with pull-requests: write permission.

Edit: I have an enterprise account so I’ve raised a support ticket to find out more.

works for me with the following permissions

permissions:
    contents: write
    pull-requests: write
    repository-projects: read
    # only required for workflows in private repositories
    actions: read

clarification

Creating the labels manually works with these permissions. but i have to create the labels

when you manually create two labels autorelease: pending and autorelease: tagged it starts working

This would explain why my older repositories continued to work, came here to note that label creation is blocked by default.

fyi i updated https://github.com/googleapis/release-please-action/issues/1072 it does only work once you’ve run it once with a PAT and then switch back to the normal github_token. It is not creating the labels.

when you manually create two labels autorelease: pending and autorelease: tagged it starts working