Issue pushing to github pages

I am currently struggling with using the gh-pages plugin. I am using Gitea for the source code for my Hugo site, it builds without an issue, but when it comes to using gh-pages plugin it wont push the updated site contents to it.

The error I get is:

Load key "/root/.ssh/id_rsa": invalid format
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Here is my pipeline:

kind: pipeline
type: docker
name: publish_blog

trigger:
  branch:
    - main
  event:
    - push

steps:
  - name: Build
    image: plugins/hugo
    settings:
      validate: true
  - name: Publish
    image: plugins/gh-pages
    settings:
       pages_directory: public
       upstream_name: git@github.com:owenmurr/owenmurr.github.io.git
       target_branch: main
       ssh_key:
         from_secret: ssh

I have added the ssh secret using cli using the following command:

drone secret update --repository owenmurr/blogsource --name ssh --data ~/.ssh/id_rsa

I have also added the secret in via the GUI aswell.

Is there anything I am missing?

In this example you are setting the secret to the string literal value "~/.ssh/id_rsa" which is why you are getting the invalid format error. If you want to read the secret from local file you need to prefix the path with the @ symbol, for example, --data @/home/.ssh/id_rsa

Thank you @bradrydzewski. That’s got rid of part of the error:

Load key "/root/.ssh/id_rsa": invalid format

I’m still getting the error with permission denied. I’ve tested from my machine and I can connect to GitHub using SSH.

Is there anything else that I’m missing?

We know git is using your key because you previously received an invalid format error (so we can rule out secret not being injected). We see git now returns a permission denied error. This would generally imply the ssh key does not have the necessary level of access, which in this case, is push access to the repository.

Is it possible your ssh key has read access to the repository, but lacks push access? You mention you tested locally and you were able to connect to GitHub, however, it was unclear to me whether you tested pushing or pulling. I believe when you configure a key in GitHub it is read only by default (see below screenshot). This would explain the Permission Denied error, but this is my best guess given the limited information I have.