VeryGoodOpenSource / very_good_workflows

Reusable GitHub workflows used at Very Good Ventures 🦄
https://workflows.vgv.dev
MIT License
293 stars 71 forks source link

could not load the saved OAuth2 credentials #172

Closed bandinopla closed 4 months ago

bandinopla commented 8 months ago

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

amanxnanda commented 7 months ago

+1

Goddchen commented 7 months ago

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

alestiago commented 7 months ago

Pinging you here @wolfenrain

Goddchen commented 7 months ago

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

KeidsID commented 6 months ago

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
tomarra commented 6 months ago

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.

Goddchen commented 6 months ago

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.