Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: docs automation for website #1082

Open
wants to merge 31 commits into
base: master
Choose a base branch
from

Conversation

AnimeshKumar923
Copy link
Contributor

Description

  • This PR introduces an automated workflow to push community files onto the website.
  • We can have several other PRs which modifies the structure of the docs present on this repo if required.
  • Bringing your kind attention on this PR and corresponding issue @alequetzalli @TRohit20 @akshatnema @derberg @sambhavgupta0705 @anshgoyalevil

Related issue(s)

Resolves #1028
Resolves #773

@sambhavgupta0705
Copy link
Member

@AnimeshKumar923
Copy link
Contributor Author

https://github.com/asyncapi/extensions-catalog/blob/master/.github%2Fworkflows%2Fupdate-extensions-in-website.yml Take inspiration from this file

I'll take a look at it 👍 @sambhavgupta0705


btw, have a look at the following PR which is of similar nature and was used to push Glee docs to website:

I took initial reference from here. Can you please explain me what's the difference between Lukasz's reference and your reference?

@sambhavgupta0705
Copy link
Member

btw, have a look at the following PR which is of similar nature and was used to push Glee docs to website:

I took initial reference from here. Can you please explain me what's the difference between Lukasz's reference and your reference?

the workflow I shared directly adds the link of the community to the edit-on-github.json config file

@sambhavgupta0705
Copy link
Member

we need to see if we need the increment of weights workflow for this workflow

@AnimeshKumar923
Copy link
Contributor Author

btw, have a look at the following PR which is of similar nature and was used to push Glee docs to website:

I took initial reference from here. Can you please explain me what's the difference between Lukasz's reference and your reference?

the workflow I shared directly adds the link of the community to the edit-on-github.json config file

Got it. Let me work on that...

Copy link

@TRohit20 TRohit20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AnimeshKumar923 From what I understand the PR is setting up a workflow such that, on push to community docs in the community repo, we want the changes to sync on the website(website repo) which means the workflow should create a PR and get auto-merged.

I have already worked on similar automation workflow previously, you can check out the workflow here for reference.

cc @sambhavgupta0705 @alequetzalli

@AnimeshKumar923
Copy link
Contributor Author

@AnimeshKumar923 From what I understand the PR is setting up a workflow such that, on push to community docs in the community repo, we want the changes to sync on the website(website repo) which means the workflow should create a PR and get auto-merged.

I have already worked on similar automation workflow previously, you can check out the workflow here for reference.

cc @sambhavgupta0705 @alequetzalli

Thanks for the reference! 👍 @TRohit20

@AnimeshKumar923
Copy link
Contributor Author

/au

@AnimeshKumar923
Copy link
Contributor Author

also, what docs will we be pushing onto the website? @alequetzalli @TRohit20
I assume the onboarding-guide will definitely be pushed as far as I know... What else? Can we have a list of it?

@TRohit20
Copy link

TRohit20 commented Mar 2, 2024

I'd suggest not to hard code the files we'd push on, use paths instead. Makes your file easier haha

@quetzalliwrites
Copy link
Member

Question, @AnimeshKumar923, is this PR to replace the one I tried to make via #1064? I don't mind at all, if that is the case, I honestly still don't understand fully how to automate pushing our community docs to the website. If someone else such as yourself is making a PR to show me how to do so, please do share. 😅

Also, sorry but I do not fully understand the code. Can you walk me through it more? 🙏🏻 cc @TRohit20

@AnimeshKumar923
Copy link
Contributor Author

Question, @AnimeshKumar923, is this PR to replace the one I tried to make via #1064? I don't mind at all, if that is the case, I honestly still don't understand fully how to automate pushing our community docs to the website. If someone else such as yourself is making a PR to show me how to do so, please do share. 😅

Also, sorry but I do not fully understand the code. Can you walk me through it more? 🙏🏻 cc @TRohit20

Hey @alequetzalli sorry about that. I didn't see that PR as it wasn't linked in the original issue, hence I missed #1064 😅

If it's fine with you, I can help with the community docs automation through this PR. 😁

@AnimeshKumar923
Copy link
Contributor Author

AnimeshKumar923 commented Mar 6, 2024

@alequetzalli
(DISCLAIMER: I'll try my best to explain, although I'm still learning so please verify the explanation @sambhavgupta0705 @akshatnema)

Automation Workflow

  • Whenever there's a docs PR on the master branch which is of .md type, the workflow gets triggered.

  • Then there are number of jobs that takes place.

  • Make-PR gets executed. Inside this, there are further sub-jobs which takes place.

  • It then checks out the specified repository (community repo here)

    steps:
      - name: Checkout Current repository
        uses: actions/checkout@v4
        with:
          path: community
  • Then it checks out another repo (which is website repo here) using the following:

    name: Checkout Another repository
        uses: actions/checkout@v4
        with:
          repository: asyncapi/website
          path: website
          token: ${{ env.GITHUB_TOKEN }}
  • After that, it configures the git

    name: Config git
        run: |
          git config --global user.name asyncapi-bot
          git config --global user.email info@asyncapi.io
  • Then it creates a new branch with commit id

    name: Create branch
        working-directory: ./website
        run: |
          git checkout -b update-community-docs-${{ github.sha }}
  • @sambhavgupta0705 please explain this part...

        name: Update edit-page-config.json
            uses: actions/github-script@v4
            with:
                script: |
                const { writeFile } = require('fs').promises;
                const configPath = './website/config/edit-page-config.json';
                const checkSlug = 'reference/extensions/';
                const slug = {
                    "value": checkSlug,
                    "href": "https://github.com/asyncapi/community/tree/master/docs"
                };
                
                const configData = require(configPath);
                const entryExists = configData.some(entry => entry.value === checkSlug);
                if (!entryExists) {
                    configData.push(slug);
                    await writeFile(configPath, JSON.stringify(configData, null, 2))
                }
        ```
    
  • After that, it copies the specified files from community repo to the website repo

    name: Copy community folder from Current Repo to Another
        working-directory: ./website
        run: |
          mkdir -p ./pages/docs/community/
          printf "%s\ntitle: Community\nweight: 7\n%s" "---" "---"> ../community/docs/_section.md
          mv ../community/docs/*.md ./pages/docs/community
  • After the files are copies, it commits and pushes the changes

    name: Commit and push
        working-directory: ./website
        run: |
          git add .
          git commit -m "docs(community): update latest community docs"
          git push https://${{ env.GITHUB_TOKEN }}@github.com/asyncapi/website
  • At last, we create a PR with title docs(community): update latest community documentation with PR body being Updated community documentation is available and this PR introduces update to community folder on the website

    name: Create PR
        working-directory: ./website
        run: |
          gh pr create --title "docs(community): update latest community documentation" --body "Updated community documentation is available and this PR introduces update to community folder on the website" --head "update-community-docs-${{ github.sha }}"

@sambhavgupta0705
Copy link
Member

@AnimeshKumar923 I will explain the whole workflow to you soon

@quetzalliwrites
Copy link
Member

NOTE: Sharing some notes that @KhudaDad414 shared with me via DM about this task in case it helps @AnimeshKumar923.


If I understood the issue correctly then this is how we approached it in glee:

@quetzalliwrites
Copy link
Member

quetzalliwrites commented Mar 7, 2024

Thank you for that extremely detailed walk-through of your code, @AnimeshKumar923!! I really appreciate it. 😀

also, what docs will we be pushing onto the website? I assume the onboarding-guide will definitely be pushed as far as I know... What else? Can we have a list of it?

Thank you, good question! We should push whatever is in the /docs directory, with the exception of the README. That leaves us with:

  1. Onboarding Guide
  2. How changes in spec are introduced

Does that make sense? lemme know ✌🏽

@AnimeshKumar923
Copy link
Contributor Author

AnimeshKumar923 commented Mar 7, 2024

Thank you for that extremely detailed walk-through of your code, @AnimeshKumar923!! I really appreciate it. 😀

My pleasure! 😁

also, what docs will we be pushing onto the website? I assume the onboarding-guide will definitely be pushed as far as I know... What else? Can we have a list of it?

Thank you, good question! We should push whatever is in the /docs directory, with the exception of the README. That leaves us with:

1. [Onboarding Guide](https://github.com/asyncapi/community/tree/master/docs/onboarding-guide)

2. [How changes in spec are introduced](https://github.com/asyncapi/community/blob/master/docs/how-changes-in-the-spec-are-introduced.md)

Does that make sense? lemme know ✌🏽

Yes, definitely. Thanks for the clarification! @alequetzalli

@AnimeshKumar923
Copy link
Contributor Author

AnimeshKumar923 commented Mar 7, 2024

NOTE: Sharing some notes that @KhudaDad414 shared with me via DM about this task in case it helps @AnimeshKumar923.

If I understood the issue correctly then this is how we approached it in glee:

* created this workflow in the glee project. https://github.com/asyncapi/glee/blob/master/.github/workflows/update-docs-in-website.yml

* adding a _section.md file in the Glee project here (https://github.com/asyncapi/glee/blob/master/docs/pages/_section.md)

* made sure all of the .md files can compile as we want them to by putting them in a local instance of the website.

* now any time we update the docs, website is going to be updated automatically.

@alequetzalli

Thanks for sharing the notes. It will definitely help in the development process of this feature. 👍


I think for the modification in the docs structure, we should have separate PRs for better management and reviews.
cc: @TRohit20

.github/workflows/update-docs-in-website.yml Outdated Show resolved Hide resolved
.github/workflows/update-docs-in-website.yml Outdated Show resolved Hide resolved
.github/workflows/update-docs-in-website.yml Outdated Show resolved Hide resolved
.github/workflows/update-docs-in-website.yml Outdated Show resolved Hide resolved
@TRohit20
Copy link

@AnimeshKumar923 Can you push the changes suggested and run the tests to check if it works as expected?

@AnimeshKumar923
Copy link
Contributor Author

@AnimeshKumar923 Can you push the changes suggested and run the tests to check if it works as expected?

@TRohit20 I'll do that. Please give me a bit more time. This week will be a bit hectic for me...😅

@quetzalliwrites
Copy link
Member

I will say that Animesh has proven to be a responsible contributor and he continues to be extremely responsive. We should be patient, cough cough @TRohit20 😛 😸

@AnimeshKumar923
Copy link
Contributor Author

UPDATE

Lukasz and I had a meet on Zoom. Here's the recording for reference and context if someone wants to watch it.

Main points to focus:

  • He explained how the workflow is executed.
  • Suggested some improvements which I'll apply shortly.
  • There is a 'wild beast' in the docs/ folder which needs to be taken care of. @alequetzalli will DM you on Slack regarding that.

cc: @TRohit20 here's the update... 😁

@sambhavgupta0705
Copy link
Member

There is a 'wild beast' in the docs/ folder which needs to be taken care of
Yeahh I was also thinking about this file

AnimeshKumar923 and others added 8 commits April 3, 2024 11:56
applied suggestion from: asyncapi#1082 (comment)

Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com>
Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com>
asyncapi#1082 (comment)

Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com>
asyncapi#1082 (comment)

Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com>
@AnimeshKumar923
Copy link
Contributor Author

I've applied the suggestions and modified the workflow file accordingly. Please have a look @derberg @sambhavgupta0705 @TRohit20

I hope it will work as expected because locally it was behaving as expected when Lukasz was running it on his system. (Present in the recording)

@quetzalliwrites
Copy link
Member

Looking forward to discussing this wild beast with you, @AnimeshKumar923 😄🐻

@AnimeshKumar923
Copy link
Contributor Author

/au

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants