Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions docs/source/contributeactiondev.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
The Concore Action Dev docs
===========================

Introduction
------------

The current implementation uses Github REST API to push code to github by authenticating with github fine grained access token (refer https://github.blog/2022-10-18-introducing-fine-grained-personal-access-tokens-for-github/)

How it works
------------

- On triggering ``contribute`` action in fri server, it executes the ``contribute.py`` script

- Let's assume the paramters provided are:
- Study Name - test study
- Study Path - F:\\example
- Author Name - test user

- It will create a new branch named ``AuthorName_StudyName`` i.e test_user_test_study in the bot repository ``parteekcoder/concore`` which references the default branch in ``parteekcoder123/concore``

.. image:: images/ca-github-branch-ref.png
:width: 700

- Now creating Github blob (refer https://docs.github.com/en/rest/git/blobs ) for each file in the directory here ``F:\\example``. After creating blobs , create a new Git tree (refer https://docs.github.com/en/rest/git/trees)

- After creating Github tree, change the refrence of the newly created branch to the that tree

.. image:: images/ca-github-working-chart.png
:width: 700

- Now the changes have been pushed to github, and for creating pull request the ``pull_request.yml`` workflow is runned which creates pull request to upstream repo using persoanl access token of upstream repo

``Note: You need to store the personal access token of upstream repo as github secret in bot repo``

Creating token for bot
----------------------

This token is used to create branches and push studies to bot repo.After pushing studies to bot repo it dispatch ``pull_request.yml`` workflow.

- Open the bot account at github and navigate as follow:


settings > Developer settings > Personal access token > Fine-grained access token > Generate New token

Or

click https://github.com/settings/personal-access-tokens/new

- Fill token name,description expiration time

- Under the ``Repository access`` section select ``Only select repositories`` to select the repository for which you want to provide the access

- Under the ``Permissions`` , provide the read-write permissions for **Contents** and **Actions** in the ``Repository permission``

- Click **Generate token** button

- Then copy the generated token and hash it using this website in base64 encoding http://www.unit-conversion.info/texttools/base64/

- Place the token in ``contribute.py`` script at https://github.com/parteekcoder/concore/blob/main/contribute.py#L7


Creating token for workflow
---------------------------

This token is used to create pull request to upstream repo using bot account as author of pull request.

- Open bot account at Github

- Create a Personal access token of bot account at https://github.com/settings/tokens/new

- Fill the details as shown below:

.. image:: images/ca-workflow-token.png
:width: 700

- Click ``Generate token`` at bottom of the page , then Copy the token

.. image:: images/ca-workflow-token-generate.png
:width: 700

- Add this token as Github secret in bot repo at https://github.com/parteekcoder123/concore-studies/settings/secrets/actions/new with name ``token``

.. image:: images/ca-workflow-secret.png
:width: 700

- Click ``Add secret``
Binary file added docs/source/images/ca-github-branch-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/images/ca-github-working-chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/images/ca-workflow-secret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/images/ca-workflow-token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ Contents
raspberrypi
concoreeditor
contributeaction

contributeactiondev