DEV Community

Raphael Borges
Raphael Borges

Posted on

A custom action to deploy mdBook

What I built

I built a Github action for automating the deployment of a compiled book.

Category Submission:

DIY Deployments - DevOps & CI/CD

App Link

https://github.com/Rapha-Borges/mdBook-action

Screenshots

Screenshot of the Github Action

Description

This Github action is designed to be triggered when a push occurs on the "main" branch of a repository. It performs a series of steps within a job named "build" on the latest version of the Ubuntu operating system.

The action utilizes a Docker container with the image "raphaelborges/mdbook:1.0.2" to compile a book located at the path "/github/workspace/book". It then executes a shell script named "copy.sh".

The "copy.sh" script creates a worktree, sets Git configuration, deletes and clears the "gh-pages" branch, copies files from specified directories, commits the changes, and pushes them to the "gh-pages" branch on the remote repository.

This action automates the process of compiling the book and deploying it to a designated location using custom settings, simplifying the workflow for users.

Link to Source Code

https://github.com/Rapha-Borges/mdBook-action

Permissive License

MIT License

Background (What made you decide to build this particular app? What inspired you?)

I built this Github action to automate the deployment of ebooks using customized configurations that better meet the needs of the projects I am involved in. The motivation behind creating this action was to streamline the process and eliminate manual steps required for ebook deployment.

How I built it (How did you utilize GitHub Actions or GitHub Codespaces? Did you learn something new along the way? Pick up a new skill?)

To build this Github action, I leveraged the power of GitHub Actions, which provides a flexible and robust platform for automating workflows. I utilized the "actions/checkout@v3" action to perform repository checkout and the "docker://" syntax to use a specific Docker container for compiling the book. The shell script, "copy.sh," was developed to handle the file copying and Git operations required for deployment.

During the development process, I gained valuable experience in utilizing GitHub Actions to orchestrate CI/CD workflows. I learned about Docker integration within GitHub Actions, enabling seamless execution of tasks in isolated environments.

Additional Resources/Info

For more information about this project, please refer to the official repository at [https://github.com/Rapha-Borges/mdBook-action].

Additionally, you can find examples of usage and implementation at the following links: [https://github.com/badtuxx/DescomplicandoPrometheus], [https://github.com/rochacbruno/py2rs].

Top comments (0)