-
I want to setup a GitHub Action, which would build two things - a wiki using MkDocs and Javadoc using Gradle’s Javadoc command - and then push those towards the repository itself, so that it can then be displayed using GitHub pages. My current workflow is setup to build the pages and all I need now is a way to push those towards the repository itself. What would be a good way to do it? The Workflow can be found here: https://github.com/botblock/JavaBotBlockAPI/blob/master/.github/workflows/build_docs.yml Other things to know: GitHub pages is set up to take the content from the docs directory to then display. So using the gh-pages branch and maybe MkDocs’ gh-deploy command isn’t a solution for me. Additionally do I need to build the wiki with MkDocs first before the Javadoc due to MkDocs deleting everything in the target-directory (docs folder). |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
You can use the git push command to push your local changes to the remote GitHub repository. Before execute the git push, you need to set the git config. A simple demo to push changes to remote in the workflow:
Here I use the bot account github-actions[bot] to set the git config. You also can set yourself account if you want. |
Beta Was this translation helpful? Give feedback.
-
So this would only push files that are in the docs directory on the workflow? Also, does this mean that the workflow already has a git-repo setup? Doesn’t it also require it to first being setup in order to push stuff, or does GitHub (Actions) already set the workflow to have the repository as a remote set? |
Beta Was this translation helpful? Give feedback.
-
All my above steps are based on having checked out the repository from the remote to the local of the runner machine.
Description: 1) The checkout action can check out the repository from the remote to the local and also generate the local repository on the runner machine, it does not only download the source files to the local. 2) In the git add command, you can specify which modified files ( <pathspec> ) you want to commit,
If yo want to commit all the modified files, you can use the -A option.
More details, you can reference here: https://git-scm.com/docs/git-add |
Beta Was this translation helpful? Give feedback.
-
Thank you very much! It works now and like I wanted it to. But before I go another small question. I currently use a workflow on another repository to automatically push changes to the gh-pages branch of said repository and created a PAT (Personal Access Token) for it. Is this even required? Because when I check my PATs is this one shown as “never used”. I have it as secret in the repo and use it when adding a remote (I guess? I assume this isn’t really needed here?)
The entire workflow:
|
Beta Was this translation helpful? Give feedback.
-
To add there is an automatically generated token Authentication in a workflow - GitHub Docs//docs.github.com/en/actions/reference/authentication-in-a-workflow |
Beta Was this translation helpful? Give feedback.
@andre601 ,
All my above steps are based on having checked out the repository from the remote to the local of the runner machine.
The basic process is following:
name: Modify/add files
. . .
name: push changes to remote
run: |
git config --global user.name "user mane"
git config --global user.email "user email"
git add <pathspec> git commit -m "commit message"
git push
Description:
1) The checkout action can check out the repository from the remote to the local and also generate the local repository on the runner machine, it does not only download the source files to the local.
2) In the git add command, you can speci…