Skip to content

Commit

Permalink
Merge pull request #2 from shiouen/feature/pipeline
Browse files Browse the repository at this point in the history
feature/pipeline
  • Loading branch information
shiouen authored Jan 15, 2024
2 parents 4cd68f5 + 0061fea commit 8dab27d
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 10 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: development

on:
push:
branches-ignore: [ main ]

env:
GO_VERSION: 1.21
HUGO_VERSION: 0.121.0
NUSHELL_VERSION: 0.88.0
SBOT_VERSION: 1.4.1

jobs:
build:
name: pipeline
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: set up go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: set up hugo
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb
sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: set up nushell
uses: hustcer/[email protected]
with:
version: ${{ env.NUSHELL_VERSION }}

- name: set up path
run: |
mkdir bin
echo "$(pwd)/bin" >> $GITHUB_PATH
- name: install semverbot
run: |
curl -o bin/sbot -L https://github.com/restechnica/semverbot/releases/download/v$SBOT_VERSION/sbot-linux-amd64
chmod +x bin/sbot
- name: prepare release
run: |
sbot update version --verbose
release_version="$(sbot predict version --verbose)"
echo "RELEASE_VERSION=${release_version}" >> $GITHUB_ENV
- name: build
run: nu run.nu build

- name: authenticate gcs
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCS_SA_KEY }}

- name: set up gcloud
uses: google-github-actions/setup-gcloud@v2
with:
version: ">= 363.0.0"

- name: authenticate aws
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: eu-central-1
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: try infra
run: nu run.nu try-infra
78 changes: 78 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: main

on:
push:
branches: [ main ]

env:
GO_VERSION: 1.21
HUGO_VERSION: 0.121.0
NUSHELL_VERSION: 0.88.0
SBOT_VERSION: 1.4.1

jobs:
build:
name: pipeline
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: set up go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: set up hugo
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb
sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: set up nushell
uses: hustcer/[email protected]
with:
version: ${{ env.NUSHELL_VERSION }}

- name: set up path
run: |
mkdir bin
echo "$(pwd)/bin" >> $GITHUB_PATH
- name: install semverbot
run: |
curl -o bin/sbot -L https://github.com/restechnica/semverbot/releases/download/v$SBOT_VERSION/sbot-linux-amd64
chmod +x bin/sbot
- name: prepare release
run: |
sbot update version --verbose
release_version="$(sbot predict version --verbose)"
echo "RELEASE_VERSION=${release_version}" >> $GITHUB_ENV
- name: build
run: nu run.nu build

- name: authenticate gcs
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCS_SA_KEY }}

- name: set up gcloud
uses: google-github-actions/setup-gcloud@v2
with:
version: ">= 363.0.0"

- name: authenticate aws
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: eu-central-1
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: deploy
run: nu run.nu deploy --infra

- name: release
run: |
sbot update version --verbose
sbot release version --verbose
sbot push version --verbose
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ themes/
.idea

### Terraform
*.terraform.*
*.terraform
terraform*
2 changes: 1 addition & 1 deletion app/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/shiouen/oliviervanaken.com

go 1.21.5
go 1.21

require github.com/adityatelange/hugo-PaperMod v0.0.0-20240107104123-71ce72b1bfb8 // indirect
24 changes: 24 additions & 0 deletions infra/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions infra/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ provider "aws" {
tags = local.tags
}
}

terraform {
backend "gcs" {
bucket = "rt-terraform-backends"
prefix = "oliviervaken.com"
}
}
4 changes: 2 additions & 2 deletions infra/resources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ resource "aws_acm_certificate" "certificate" {
subject_alternative_names = [local.domain_name]
validation_method = "DNS"

provider = "aws.us-east-1"
provider = aws.us-east-1
}

resource "aws_acm_certificate_validation" "certificate_validation" {
certificate_arn = aws_acm_certificate.certificate.arn

provider = "aws.us-east-1"
provider = aws.us-east-1
}

resource "aws_cloudfront_distribution" "distribution" {
Expand Down
35 changes: 30 additions & 5 deletions run.nu
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
const app_path = "app"
const infra_path = "infra"

let env_vars = (open env.json)
const env_path = "env.json"
mut mut_env_vars = {}

if ($env_path | path exists) {
$mut_env_vars = (open env.json)
}

let env_vars = $mut_env_vars

def build-app [] {
echo "building app..."
Expand All @@ -18,9 +25,7 @@ def clean-app [] {

def clean-infra [] {
echo "cleaning up terraform..."
cd $infra_path
rm -rf .terraform.*
rm -rf *.tfstate*
rm -rf $"($infra_path)/**/*.tfstate*"
}

def deploy-app [] {
Expand All @@ -42,7 +47,7 @@ def deploy-infra [approve: bool = false] {

terraform init

let options = {
mut options = {
approve: ""
}

Expand All @@ -53,17 +58,37 @@ def deploy-infra [approve: bool = false] {
run-external terraform apply $options.approve
}

def init-infra [] {
echo "initializing infra..."
cd $infra_path
terraform init
}

def load-env-vars [] {
echo "loading env vars..."
load-env $env_vars
}

def try-infra [] {
echo "trying infra..."
cd $infra_path
terraform plan
}

def "main build" [] {
build-app
}

def "main try-infra" [] {
with-env $env_vars {
init-infra
try-infra
}
}

def "main clean" [] {
clean-app
clean-infra
}

def "main deploy" [--infra (-i)] {
Expand Down

0 comments on commit 8dab27d

Please sign in to comment.