very_good_workflows icon indicating copy to clipboard operation
very_good_workflows copied to clipboard

could not load the saved OAuth2 credentials

Open bandinopla opened this issue 2 years ago • 7 comments

Description Action fails to run because it can't load the credentials:

Warning: could not load the saved OAuth2 credentials.
Obtaining new credentials...
Pub needs your authorization to upload packages on your behalf.

I'm running this workflow:

jobs:
  build:
    uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_pub_publish.yml@v1
    with: 
      pub_credentials: secrets.PUB_CREDENTIALS

in PUB_CREDENTIALS y copy & pasted the contents of pub-credentials.json

https://workflows.vgv.dev/docs/workflows/flutter_pub_publish#example-usage

bandinopla avatar Jan 27 '24 17:01 bandinopla

+1

amanxnanda avatar Feb 06 '24 13:02 amanxnanda

Also using ${{ secrets.PUB_CREDENTIALS }} doesn't work.

Goddchen avatar Feb 26 '24 08:02 Goddchen

Pinging you here @wolfenrain

alestiago avatar Feb 26 '24 10:02 alestiago

My guess is you should be using secrets over inputs for the secret.

Goddchen avatar Feb 26 '24 18:02 Goddchen

It needs base64 support on credentials to make it work:

name: Publish to pub.dev

on:
  push:
    tags:
      - "v[0-9]+.[0-9]+.[0-9]+"

jobs:
  publish:
    defaults:
      run:
        working-directory: "."

    runs-on: ubuntu-latest
    timeout-minutes: 5

    strategy:
      matrix:
        flutter-version: [3.10.x]
        flutter-channel: [stable]

    steps:
      - name: 📚 Git Checkout
        uses: actions/checkout@v4

      - name: 🐦 Setup Flutter
        uses: subosito/flutter-action@v2
        with:
          flutter-version: ${{ matrix.flutter-version }}
          channel: ${{ matrix.flutter-channel }}
          cache: true

      - name: 📦 Install Dependencies
        run: flutter pub get

      - name: 🔐 Setup Pub Credentials
        run: |
          mkdir -p $XDG_CONFIG_HOME/dart
          echo '${{secrets.PUB_CREDENTIALS}}' | base64 --decode > "$XDG_CONFIG_HOME/dart/pub-credentials.json"

      - name: 🌵 Dry Run
        run: flutter pub publish --dry-run

      - name: 📢 Publish
        run: flutter pub publish -f

KeidsID avatar Mar 12 '24 17:03 KeidsID

Thanks @KeidsID for the info here. Seems like this is something we can add into the documentation to make sure others don't fall into this.

Adding the Documentation tag here as that seems like the right change here.

tomarra avatar Mar 25 '24 14:03 tomarra

I don't think that is the right way to tackle this. You need to properly use secrets over inputs, that will fix all the issues. No workarounds needed.

Goddchen avatar Mar 25 '24 15:03 Goddchen