I'm stucked trying to launch a Github actions workflow. The Flutter project has a dependency of a custom package. I have this custom package in a Github repository. This is the way I set up this dependency in the pubspec.yaml:
xxxx_package:
git:
url: git@github.com:USER_NAME/xxxx_package.git
ref: develop
If I launch flutter pub get command, it ends successful and I can build and execute the app without problems.
But when I send a push to Github and it launches the workflow, the process finish with this error:
Running "flutter pub get" in Project-Flutter...
Git error. Command: `git clone --mirror git@github.com:xxx/xxxx_package.git /home/runner/.pub-cache/git/cache/xxxx_package-123456789`
stdout:
stderr: Cloning into bare repository '/home/runner/.pub-cache/git/cache/xxxx_package-123456789'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
This is my actions workflow file:
name: Check merge
on:
push:
branches: [ main, develop ]
pull_request:
branches: [main, develop]
workflow_dispatch:
jobs:
build:
name: flutter environment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2
with:
flutter-version: '2.8.1'
- name: Install dependencies
run: flutter pub get
- run: flutter format --set-exit-if-changed .
- run: flutter analyze .
- run: flutter test
I have configured the custom package repository to work with shh.
UPDATE 02/17/2022
I tried the @GuiFalourd suggestion but not working.
I've added to both repos (main project and private repo) two secrets (same for both).
- KNOWN_HOSTS
- SSH_PRIVATE_KEY -> This is the content -----BEGIN RSA PRIVATE KEY----- ssh-ed25519 "SSH_KEY" -----END RSA PRIVATE KEY-----
But this is the output:
IO : Finished git. Exit code 128.
| Nothing output on stdout.
| stderr:
| | Cloning into bare repository '/home/runner/.pub-cache/git/cache/xxxx_package-363daa26604baf2e3bfeae08af7d9c7050760631'...
| | Warning: Permanently added the ECDSA host key for IP address 'x.x.x.x' to the list of known hosts.
| | Load key "/home/runner/.ssh/id_rsa": invalid format
| | git@github.com: Permission denied (publickey).
| | fatal: Could not read from remote repository.
| |
| | Please make sure you have the correct access rights
| | and the repository exists.