actions / create-github-app-token

GitHub Action for creating a GitHub App Installation Access Token
https://github.com/marketplace/actions/create-github-app-token
MIT License
321 stars 46 forks source link

Generate a personal access token (classic) to access maven reposiotry #129

Closed pawel-jedruch-swiftpay closed 3 months ago

pawel-jedruch-swiftpay commented 3 months ago

We do have two private repositories in our organization, let's call them: library and project. The library is hosted in the Maven GitHub repository. The project workflow is using a personal access token for authorization (according to documentation.

Now we want to migrate to actions/create-github-app-token, but I was unable to create a working solution.

.github/workflows/example.yml ```yaml jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Get token from Github App uses: actions/create-github-app-token@v1 id: app-token with: app-id: ${{ secrets.GET_TOKEN_APP_ID }} private-key: ${{ secrets.GET_TOKEN_APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} - name: Set up Maven uses: actions/setup-java@v4 with: java-version: '17' distribution: 'corretto' cache: 'maven' server-username: MAVEN_USERNAME server-password: MAVEN_PASSWORD - name: Build and Package run: | cd project mvn clean package env: MAVEN_USERNAME: ${{ github.actor }} MAVEN_PASSWORD: ${{ steps.app-token.outputs.token }} ```

I've tried multiple configurations but always end up with the following error:

Authentication failed for https://maven.pkg.github.com//repo/..., status: 401 Unauthorized -> [Help 1]

What I'm guessing is that create-github-app-token doesn't support a personal access token. Could you confirm if this is the case?

gr2m commented 3 months ago

What I'm guessing is that create-github-app-token doesn't support a personal access token. Could you confirm if this is the case?

That is correct, actions/create-github-app-token creates installation access token (server-to-server tokens). Personal access tokens cannot be created programmatically without user interaction.

Authentication failed for https://maven.pkg.github.com//repo/...

The // looks odd, maybe an argument is missing, like an org name? I'm not familiar with maven I'm afraid