Context
We have our open source project on GitHub repos, but we are still using Azure DevOps Pipelines to run our builds.
One of the steps in the build is the generation of documentation (using lazydocs for Python). This generates some new .md files in a folder. And I want to make sure these files are being added + committed into the actual branch and merge that is happening in the Pull Request.
Build file
Below are the relevant steps/actions from my current ci-build.yaml file, leaving the non-relevant steps out.
name: $(date:yyyyMMdd)$(rev:rr)
trigger:
branches:
include:
- master
paths:
include:
- arcus/*
pr:
paths:
include:
- arcus/*
# Leaving out stuff for templates, vmimages, etc
- script: |
git checkout $(System.PullRequest.SourceBranch)
displayName: 'Checkout build branch'
# Install Python tools and packages
- script: |
lazydocs --output-path docs/preview arcus/ml
git config --global --add url."git@github.com:".insteadOf "https://github.com/"
git config user.email "first.last@domain.eu"
git config user.name "User"
git add docs/preview
git commit -m "Add SDK docs from Build $(Build.BuildId) [skip ci]"
git push origin $(System.PullRequest.SourceBranch)
displayName: 'Generate code documentation'
continueOnError: false
# Remaining actions to build & publish packages
Problems
Terminal prompts disabled
The following error was thrown at a point in time:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
And it read that I could avoid that, by adding the following command in the git part:
git config --global --add url."git@github.com:".insteadOf "https://github.com/"
Permission denied (publickey) error
So, when I remove that git config line from that script action, I get the following error:
Warning: Permanently added the RSA host key for IP address 'XXX.XX.XXX.X' to the list of known hosts. 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.
Question
So, my main question is: how should I solve the above errors? How can I make sure to commit files in the CI build, ideally by using the identity/context of the actual GitHub user, triggering the CI-build?
Thanks in advance