Create workflow for CI/CD updates on the live mdbooks #32

Open
opened 2024-04-04 15:35:14 +00:00 by mik-tf · 4 comments
Owner

Goal

Ensure the latest book versions are always available online (main branch)

Feature Request

  • Create workflow for CI/CD updates on the live mdbooks
  • Like we have on github.com/threefoldtech/info_grid
    • when we push to main, the website on mdbooks are updated

@thabeta
@despiegk

Current Situation

  • for now Kristof can run the scrcipt in books of each book

Potential Solution

  • we set a publication script to run all scripts (books in main) at every push to main on the server hosting the repo
# Goal Ensure the latest book versions are always available online (main branch) # Feature Request - Create workflow for CI/CD updates on the live mdbooks - Like we have on github.com/threefoldtech/info_grid - when we push to main, the website on mdbooks are updated @thabeta @despiegk # Current Situation - for now Kristof can run the scrcipt in books of each book # Potential Solution - we set a publication script to run all scripts (books in main) at every push to main on the server hosting the repo
mik-tf added this to the ThreeFold 3.14 - info_tfgrid docs project 2024-05-16 16:41:41 +00:00
Author
Owner

@despiegk can you enable Actions on gitea?
I think it needs to be done on the server side?

https://blog.gitea.com/feature-preview-gitea-actions/

Or maybe we want to proceed differently? We can discuss.

  • The .yaml file would be the following.
    • This include the script that publish the books.
  • this would be publish_books.yaml in info_tfgrid/.gitea/workflows/publish_books.yaml
name: Publish Books

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Publish books after main push
        run: |
        #!/bin/bash
        set -ex

        # Clone and cd into the repo
        repo_name="info_tfgrid"
        git_url="https://git.ourworld.tf/tfgrid/$repo_name"

        if [ ! -d "$repo_name" ]; then
            git clone "$git_url"
            echo "Repository cloned successfully"
        else
            echo "Repository already exists"
        fi

        cd info_tfgrid/heroscript

        dir_path="${PWD}"
        arr=()

        # Save each book into a list named arr
        for subdir in "$dir_path"/*; do
            # Check if the item is a directory
            if [ -d "$subdir" ]; then

            # Add the subdirectory name to the array
            basesubdir=$(basename "$subdir")

            # Add the subdirectory name to the array
            arr+=("$basesubdir")
            fi
        done

        # Publish each book from the info_tfgrid repository (/heroscript)
        for NAME in "${arr[@]}"; do
            echo $NAME
            hero mdbook -u https://git.ourworld.tf/tfgrid/info_tfgrid/src/branch/main/heroscript/$NAME
            rsync -rv ~/hero/www/info/$NAME/ root@info.ourworld.tf:/root/hero/www/info/$NAME/
        done

Todo

  • enable actions
  • add runner on server (runner docs)
  • make new PR with this workflow
@despiegk can you enable Actions on gitea? I think it needs to be done on the server side? https://blog.gitea.com/feature-preview-gitea-actions/ Or maybe we want to proceed differently? We can discuss. - The .yaml file would be the following. - This include the script that publish the books. - this would be publish_books.yaml in info_tfgrid/.gitea/workflows/publish_books.yaml ``` name: Publish Books on: push: branches: - main jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Publish books after main push run: | #!/bin/bash set -ex # Clone and cd into the repo repo_name="info_tfgrid" git_url="https://git.ourworld.tf/tfgrid/$repo_name" if [ ! -d "$repo_name" ]; then git clone "$git_url" echo "Repository cloned successfully" else echo "Repository already exists" fi cd info_tfgrid/heroscript dir_path="${PWD}" arr=() # Save each book into a list named arr for subdir in "$dir_path"/*; do # Check if the item is a directory if [ -d "$subdir" ]; then # Add the subdirectory name to the array basesubdir=$(basename "$subdir") # Add the subdirectory name to the array arr+=("$basesubdir") fi done # Publish each book from the info_tfgrid repository (/heroscript) for NAME in "${arr[@]}"; do echo $NAME hero mdbook -u https://git.ourworld.tf/tfgrid/info_tfgrid/src/branch/main/heroscript/$NAME rsync -rv ~/hero/www/info/$NAME/ root@info.ourworld.tf:/root/hero/www/info/$NAME/ done ``` # Todo - enable actions - add runner on server ([runner docs](https://docs.gitea.com/usage/actions/act-runner)) - make new PR with this workflow
Author
Owner

@timur is working on this as discussed with @despiegk

@timur is working on this as discussed with @despiegk
mik-tf reopened this issue 2024-06-10 13:15:11 +00:00
Author
Owner

@timur

Kristof said you complete this.

Can you give us a status of the CI/CD?
Is there anything we need to do on our end?

Thanks! I will be more than amazing.

If it's done we can just close the issue.

I'll make a subsequent issue to document the procedures of the CI/CD if needed.

@timur Kristof said you complete this. Can you give us a status of the CI/CD? Is there anything we need to do on our end? Thanks! I will be more than amazing. If it's done we can just close the issue. I'll make a subsequent issue to document the procedures of the CI/CD if needed.
Author
Owner

@timur

Hi Timur! I hope you're doing good :)

So the books are done. You can put them all to live with: https://threefold.info/book_name as discussed

Library book contains links to all the books (https://threefold.info/library)

If possible simply push the books live on the dev server. Thanks!!

@timur Hi Timur! I hope you're doing good :) So the books are done. You can put them all to live with: https://threefold.info/book_name as discussed Library book contains links to all the books (https://threefold.info/library) If possible simply push the books live on the dev server. Thanks!!
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: tfgrid/info_tfgrid#32
No description provided.