mirror of
https://github.com/acaloiaro/garbagespeak.com
synced 2026-07-21 18:29:08 +00:00
Add build workflow
This commit is contained in:
parent
be225c6357
commit
ba46630a35
3 changed files with 136 additions and 1 deletions
65
.github/workflows/build.yml
vendored
Normal file
65
.github/workflows/build.yml
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
name: goreleaser
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: "1.20"
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v2
|
||||
with:
|
||||
hugo-version: '0.115.4'
|
||||
extended: true
|
||||
- name: Hugo Build
|
||||
run: hugo --minify
|
||||
- name: Garbagespeak Build
|
||||
run: |
|
||||
mkdir out
|
||||
go build -o "out/garbage-speak-${GITHUB_SHA}" server.go
|
||||
- name: S3 Sync
|
||||
uses: jakejarvis/s3-sync-action@v0.5.1
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.B2_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.B2_SECRET_ACCESS_KEY }}
|
||||
AWS_S3_BUCKET: "garbage-speak-application"
|
||||
AWS_REGION: "us-east-005"
|
||||
AWS_S3_ENDPOINT: "https://s3.us-east-005.backblazeb2.com "
|
||||
SOURCE_DIR: "out"
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Tailscale Login
|
||||
uses: tailscale/github-action@main
|
||||
with:
|
||||
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
|
||||
version: 1.32.1
|
||||
env:
|
||||
ADDITIONAL_ARGS: "--accept-dns"
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Deploy nomad job
|
||||
run: |
|
||||
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
|
||||
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
|
||||
sudo apt-get update && sudo apt-get install nomad
|
||||
tailscale status
|
||||
nomad job run -var version=${GITHUB_SHA} -var b2_access_key_id=${B2_ACCESS_KEY_ID} -var b2_secret_access_key=${B2_SECRET_ACCESS_KEY} job.nomad.hcl
|
||||
env:
|
||||
NOMAD_ADDR: http://cluster-0:4646
|
||||
NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }}
|
||||
B2_ACCESS_KEY_ID: ${{ secrets.B2_ACCESS_KEY_ID }}
|
||||
B2_SECRET_ACCESS_KEY: ${{ secrets.B2_SECRET_ACCESS_KEY }}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# The domain name wher ethe site is available in production
|
||||
# The domain name where the site is available in production
|
||||
SITE_DOMAIN=<SITE_DOMAIN>
|
||||
|
||||
# The host where the Hugo site is available
|
||||
|
|
|
|||
70
job.nomad.hcl
Normal file
70
job.nomad.hcl
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
variable "version" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "b2_access_key_id" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "b2_secret_access_key" {
|
||||
type = string
|
||||
}
|
||||
|
||||
job "garbage_speak" {
|
||||
datacenters = ["dc1"]
|
||||
namespace = "default"
|
||||
|
||||
group "task" {
|
||||
network {
|
||||
port "garbage_speak" {
|
||||
to = 1314
|
||||
host_network = "private"
|
||||
}
|
||||
}
|
||||
|
||||
task "garbage_speak" {
|
||||
driver = "exec"
|
||||
|
||||
config {
|
||||
command = "garbage-speak-${var.version}"
|
||||
}
|
||||
|
||||
artifact {
|
||||
source = "s3://s3.us-east-005.backblazeb2.com/garbage-speak-application/garbage-speak-${var.version}"
|
||||
options {
|
||||
aws_access_key_id = var.b2_access_key_id
|
||||
aws_access_key_secret = var.b2_secret_access_key
|
||||
# Leave the archive in tar format
|
||||
archive = false
|
||||
}
|
||||
}
|
||||
|
||||
template {
|
||||
data = <<EOF
|
||||
{{ with nomadVar "nomad/jobs/garbage_speak" }}POSTGRES_URL=postgresql://{{ .POSTGRES_USER }}:{{ .POSTGRES_PASSWORD }}{{end}}@{{ range nomadService "postgres" }}{{ .Address }}:{{ .Port }}{{ end }}/garbage_speak?sslmode=disable
|
||||
{{ with nomadVar "nomad/jobs/garbage_speak" }}SMTP_PASSWORD={{ .SMTP_PASSWORD }}
|
||||
SMTP_USER={{ .SMTP_USER }}
|
||||
SMTP_HOST={{ .SMTP_HOST }}{{ end }}
|
||||
GO_ENV=production
|
||||
SITE_DOMAIN=garbagespeak.com
|
||||
EOF
|
||||
destination = "local/env"
|
||||
env = true
|
||||
}
|
||||
|
||||
env {
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 1024
|
||||
memory = 1024
|
||||
}
|
||||
|
||||
service {
|
||||
port = "garbage_speak"
|
||||
name = "garbage-speak"
|
||||
provider = "nomad"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue