Documentation with Continuous Delivery Pipeline using VuePress, S3 and Buddy Works
Tags: continuousdelivery, vuepress, vue, s3
Published: 2018-08-01 01:26:50

---
title: Documentation with Continuous Delivery Pipeline using VuePress, S3 and Buddy Works
published: true
tags: continuous-delivery,vuepress,vuejs,s3
canonical_url: 
---

![](https://cdn-images-1.medium.com/max/600/0*G6f3Yd5joymz5MzS.png)

The other day, I was told I can create a Continuous Delivery pipeline for the documentation for the project and I said yes and for this particular case we use [VuePress](https://vuepress.vuejs.org/), which is the new tool by Evan You, the creator of VueJS, to create documentation for your site. We create something simple for it but the curiosity of how can I improve the pipeline started to work and then, this article came up.

### Prerequisites

- An AWS Account
- [NodeJS](https://nodejs.org) (Version must be ≥ 8)
- [Yarn](https://yarnpkg.com/en/)
- A [Buddy Works CI/CD](https://buddy.works/) account
- A [Github](https://github.com/) Account

### Code Ready Example

If you just want to test the pipeline and skip the development part (doing your own documentation), you can fork this project ready for S3 deployment and start experimenting with it.

[jefer590/vuepress-s3-cd-example](https://github.com/jefer590/vuepress-s3-cd-example)

### Setup Project

First we will need to init a new NodeJS project using yarn using the next command:

```
$ yarn init
```

Then, it’s time to install the only dependency for this project that is [VuePress](https://vuepress.vuejs.org/)

$ yarn add -D vuepress

After that, you must follow the [Getting Started Guide](https://vuepress.vuejs.org/guide/getting-started.html#inside-an-existing-project) of VuePress. If you have it ready, let’s move on!

### Setup Pipeline

Create a new public or private project on Github, you can name it however you want.

We need another config before jumping into Buddy Works and that is creating a programmatically user on [AWS IAM](https://aws.amazon.com/iam/) that will allow Buddy Works, deploy the built assets into an S3 bucket and, obviously, an S3 bucket configured to support Static Web Pages.

In the AIM dashboard, you have to go to _Users > Add User_ and then, in the next page, you will write the AIM username with programmatic access

![](https://cdn-images-1.medium.com/max/1024/1*H6VpflfqiVpmWfTlSsxpMg.png)

In the permissions screen, you will attach an existing policy. For demonstration purposes, we will use the **_“AmazonS3FullAccess”_** policy. You can create your own policy with only the necessary permissions for Buddy Works and you can check them [in this link](https://buddy.works/knowledge/deployments/list-of-aws-policies)

![](https://cdn-images-1.medium.com/max/1024/1*B9A-jtXlG5gjpXslsnJy3Q.png)

In the next screen, verify the info for your user and click on **_“Create User”_** and in the next screen you will get the Access Key ID and the Secret Access Key. save this info because you will use it later.

![](https://cdn-images-1.medium.com/max/1024/1*bNMlW5UG5D2z8wsqgzI1vA.png)<figcaption>Our user is ready, thanks IAM!</figcaption>

It’s time to create our S3 Bucket! go to the S3 dashboard and click in the button **_“Create Bucket”_** and a modal will appear to start creating the bucket. On the first step, add a bucket name that will be part of your domain name and select your preferred region.

![](https://cdn-images-1.medium.com/max/1024/1*wAyBwO4Q5swqibhdctaZPg.png)

On the next step, you will add **_“Versioning”_** to the bucket. Static Web Site config comes later.

![](https://cdn-images-1.medium.com/max/1024/1*JQb0-gc5EtOC-nfPO9EiJw.png)

Next step, grant read access to all the users.

![](https://cdn-images-1.medium.com/max/1024/1*KD6Zzu6P3PYg1QwO34-h_Q.png)

The last step is review your options and that’s it! you have a brand new S3 bucket but only one thing is left, set up the web host for this bucket and for that, in the dashboard of your bucket, go to **_Properties_** and then click on **_“Static Web Hosting”_**

![](https://cdn-images-1.medium.com/max/1024/1*JFO7YQdezC2JOy7Sx_QpNg.png)

A bunch of options will appear again, click on **_“Use this bucket to host a website”_**. On **_Index document_** you will put the value **_“index.html”_** and on **_Error document_** you will add the value **_“404.html”_**. Both files are generated by the VuePress building process. You save and that’s it! Everything is ready on AWS.

![](https://cdn-images-1.medium.com/max/1024/1*Y7EJJCDfbkv6daJe7o-okA.png)

Now let’s go to the fun part, configure the pipeline! Go to your Buddy Works Projects dashboard and click on **_“Create a new project”_**

![](https://cdn-images-1.medium.com/max/1024/1*uiIV89fDsimFnjaqTsf0dA.png)

Then, a list with all your repos will appear. Search the one that you created for the VuePress Project

![](https://cdn-images-1.medium.com/max/1024/1*PqfZn-6hC7fZioUIek79dg.png)

After you selected your project, the pipeline dashboard for that project will appear. Click on **_“Add a new pipeline”_**

![](https://cdn-images-1.medium.com/max/1024/1*TTQpEz_g2YwkfmUTxBa5jQ.png)

In the next screen, we will set how the pipeline will be triggered and which branch or tag you want it to be triggered. In my case, I’ll trigger this pipeline every push to master. You can add a target website to preview the deployed project. For this case, we will use the S3 static website url which the pattern is <bucket-name>.s3-website-<AWS-region>.amazonaws.com

![](https://cdn-images-1.medium.com/max/1024/1*VY3Fuwzel3Tzb-Ns5NY2yg.png)

After that, a screen to chose a new action for your pipeline. Since we need to build the VuePress project to upload it into our S3 bucket, we will use a node action.

![](https://cdn-images-1.medium.com/max/1024/1*RyAdJUGkXHvSLNBvXHECDQ.png)

Time to configure our task! We need yarn to build download the packages and download everything, so let’s install yarn in this action. Go to **_“Environment Customization”_** and add the next command $ npm install -g yarn and to try that yarn is installed, in the command screen, use the$ yarn -v command. Save the action and let’s run manually our task clicking in the _“Run Pipeline”_ button

![](https://cdn-images-1.medium.com/max/251/1*ugds9dR-L2kmUPeY90c5Gg.png)

If everything went fine, check the logs of your node action and you will see the latest yarn version

![](https://cdn-images-1.medium.com/max/1024/1*S3TQMn_SUhmhN4T1VZAj9g.png)

All right! Yarn is ready in our pipeline, let’s add the build action into out Node Task! Use the command $ yarn and$ yarn build:docs to install dependencies and build the docs.

![](https://cdn-images-1.medium.com/max/1024/1*_sJRNV0qZIqbFjebKxDyTQ.png)

The last thing needed is set the Node Runtime to grab the latest 8 version of node from the Docker Public Hub

![](https://cdn-images-1.medium.com/max/1024/1*unfODlz05Gh10YkNQZPegw.png)

At last, we have our first action made on node!!!

![](https://cdn-images-1.medium.com/max/1024/1*FH5IVuQ1RX3CNu1CmsL7VA.png)<figcaption>Our brand new action is ready!</figcaption>

The build should be good! Now let’s actually upload all our documentation into our S3 bucket. Create another action for the pipeline but this time search for a S3 action. It will ask for you S3 User Access Key ID and Secret Access Key. Use the one that you created with the S3 policy.

![](https://cdn-images-1.medium.com/max/1024/1*chDTNQ1FlozZOUcEkPPIUw.png)

If the integration went fine, a screen with the S3 upload config should appear. Make sure that you are using the **_“Pipeline Filesystem”_** to use the build archives in the past action and make sure that your source path is /docs/.vuepress/dist

![](https://cdn-images-1.medium.com/max/1024/1*2gOqF-1wybzp1HtOt4dwRg.png)

Also, make sure that you will use the S3 account for this action and you will upload everything to the root of the bucket with public access. At last, set a name for your action.

![](https://cdn-images-1.medium.com/max/1024/1*iX0g_80PeM1rj2JirrF83Q.png)

Click on **_“Add This Action”_** to finish and have our second action in our pipeline

![](https://cdn-images-1.medium.com/max/1024/1*da1Z3i-uz0mUrrWsw8G3xA.png)

Everything is going well, we have a step to build and a step to upload but I think the only thing left is an action to notify me when this was deployed successfully. Let’s do that with an email by creating a new email action.

![](https://cdn-images-1.medium.com/max/1024/1*osYTRlZl_4FwZZE5v1ngLQ.png)

Let’s add a successful message to the email that we are going to notify

![](https://cdn-images-1.medium.com/max/1024/1*MbWf3jUAIrWrt_Xr6yjlFQ.png)

And at last, let’s add the name of the action.

![](https://cdn-images-1.medium.com/max/1024/1*Uq1KDPL7omyZjp0PNDqgfQ.png)

Our pipeline should looks like this.

![](https://cdn-images-1.medium.com/max/1024/1*I7coS2XTYBB-d5GiTBd-_Q.png)<figcaption>Beautiful!</figcaption>

Now, it’s the time of truth. let’s test our new pipeline by clicking on **Run Pipeline** button. If everything was successful you may see your pipeline as _completed_ and you may received an email.

![](https://cdn-images-1.medium.com/max/1024/1*b9jN_kKkOQ8r3onhHKPWoQ.png)<figcaption>Everything went right on Buddy Works!</figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*4jNmKE3ns8UtqhW-kxgcEQ.png)<figcaption>I received the email!</figcaption>

And, of course, our site must be online.

![](https://cdn-images-1.medium.com/max/1024/1*UlRRw8FL8i8QunwOSvpC2w.png)<figcaption>Our site works wonderfully!</figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*VIKak45G3d5w1CX0lucRxA.png)<figcaption>The work done in the repo looks nice!</figcaption>

### Conclusion

With buddy we can create CI/CD workflow so nice, so easy and so wonderful. VuePress is an excellent tool for Static Documentation because of the uses of Markdown + Vue Componentes + templates. If we keep uploading changes to this repo, the repo will trigger automatically. I suggest you to check it out!

#### 🙌 Thanks for reading and see you on the next time 🙌