initial commit

This commit is contained in:
Adriano Caloiaro 2025-06-27 07:10:53 -06:00
commit a7cbadf2d5
No known key found for this signature in database
GPG key ID: C2BC56DE73CE3F75
3 changed files with 94 additions and 0 deletions

45
.github/workflows/deploy.yml vendored Normal file
View file

@ -0,0 +1,45 @@
name: Build and deploy
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Tailscale login
uses: tailscale/github-action@v3
with:
version: 1.82.5
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
tags: tag:github-action
- name: Build application
run: |
docker build . -f Dockerfile -t "camply:${GITHUB_SHA}"
docker save "camply:${GITHUB_SHA}" -o "camply-${GITHUB_SHA}.tar"
- name: Serve docker image to nomad client(s)
uses: Eun/http-server-action@v1
with:
directory: ${{ github.workspace }}
port: 8080
no-cache: false
log: "log.txt"
logTime: "false"
- name: Setup `nomad`
uses: hashicorp/setup-nomad@main
id: setup
with:
version: 1.9.7
- name: Deploy nomad job
run: |
tailscale status
nomad job run -var version=${GITHUB_SHA} -var runner_name=github-$(hostname -s) job.nomad.hcl
env:
NOMAD_ADDR: http://ncm-0:4646
NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }}

3
Dockerfile Normal file
View file

@ -0,0 +1,3 @@
FROM juftin/camply:0.32.9
CMD ["camply", "campsites", "--start-date", "2025-07-06", "--end-date", "2025-07-09", "--campground", "232492", "--equipment", "trailer", "25", "--continuous", "--notifications", "pushover"]

46
job.nomad.hcl Normal file
View file

@ -0,0 +1,46 @@
variable "version" {
type = string
}
variable "runner_name" {
description = "The name of the github runner ($GITHUB_RUNNER)"
type = string
}
job "camply_glacier_2025" {
datacenters = ["dc1"]
namespace = "default"
group "task" {
count = 1
task "camply" {
driver = "docker"
artifact {
source = "http://${var.runner_name}:8080/camply-${var.version}.tar"
options {
archive = false
}
}
config {
load = "camply-${var.version}.tar"
image = "camply:${var.version}"
}
template {
data = <<EOF
{{ with nomadVar "nomad/jobs/camply_glacier_2025/task/camply" }}PUSHOVER_PUSH_USER={{ .PUSHOVER_PUSH_USER }}
PUSHOVER_PUSH_TOKEN={{ .PUSHOVER_PUSH_TOKEN}}{{ end }}
EOF
destination = "local/env"
env = true
}
resources {
cpu = 128
memory = 128
}
}
}
}