Codepipeline 練習 deploy blog

以 build & deploy blog 練習使用 CodePipeline 相關 service。

  1. 在 CodeCommit 開 repository,把 blog source 放上去。CodeCommit 是類似 Github 的 AWS service。
  2. CodePipeline 的 Source stage 設定 source 為 CodeCommit。
  3. Build stage 使用 CodeBuild,image 用 AWS 的 Ubuntu image。
  4. 在 source code 裡加入 buildspec.yml,讓 CodeBuild 知道要跑什麼,內容如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
version: 0.2

phases:
install:
on-failure: ABORT
commands:
- ./blog init
build:
on-failure: ABORT
commands:
- ./blog g

artifacts:
files:
- '**/*'
base-directory: public
name: blog-$(date +%Y-%m-%d)
  1. deploy stage 設定 deploy 到 S3 的 static web hosting bucket。

pipeline 會在 push code 後自動開始跑,一路 build 出 static html、deploy 到 S3。source stage 跟 build stage 的 artifact 會存到 S3。

Ref