delete-package-versions
delete-package-versions copied to clipboard
Error when using delete-package-versions from a different repo
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.
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