Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using delete-package-versions from a different repo #108

Open
eric-creekside opened this issue Jul 17, 2023 · 1 comment
Open

Comments

@eric-creekside
Copy link

I'm using delete-package-versions as part of a reusable workflow that I call from others. It works as long as my reusable workflow and the calling workflow are in the same repo as the package is hosted. But when I try to call it from a workflow in a different repo (owned by the same account), it fails with Error: get versions API failed. Resource not accessible by integration

Here's my reusable workflow:

name: _ Publish with Gradle

on:
  workflow_call:
    inputs:
      project-folder:
        required: false
        type: string
        default: .
      package-name:
        required: true
        type: string
      java-version:
        type: string
        default: '17'

jobs:
  gradle-publish:

    runs-on: ubuntu-latest

    permissions:
      contents: read
      packages: write

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Set up JDK ${{ inputs.java-version}}
        uses: actions/setup-java@v3
        with:
          java-version: ${{ inputs.java-version}}
          distribution: 'temurin'

      - name: Gradle publish
        uses: gradle/gradle-build-action@v2
        with:
          arguments: publish --scan
          build-root-directory: ${{ inputs.project-folder }}

      - name: 'Clean old pre-release versions'
        uses: actions/delete-package-versions@v4
        with: 
          package-name: ${{ inputs.package-name }}
          package-type: 'maven'
          min-versions-to-keep: 10
          delete-only-pre-release-versions: true

Here's an example of calling that workflow:

name: Publish my-lib library

on:
  workflow_dispatch:
  push:
    branches:
      - master
      - release/**

jobs:
  publish_my-lib:
    uses: ./.github/workflows/gradle-publish-project.yml
    with:
      java-version: '17'
      package-name: 'com.me.my-lib'

The actual publish works correctly, but for some reason the delete-package-versions step fails when it's cross-repo. I've enabled read-write permissions on the repos.

@wolveix
Copy link

wolveix commented Dec 15, 2023

I know this is an old issue, but if anyone else stumbles across this, check your repo's settings: Actions -> Workflow settings -> Read and write permissions

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

No branches or pull requests

2 participants