From 5903ce9c56a9f0d03dd121a98ca022cd14f212ab Mon Sep 17 00:00:00 2001 From: Elara Musayelyan Date: Fri, 9 Jun 2023 12:10:29 -0700 Subject: [PATCH] Add nomad template --- .goreleaser.yaml | 7 +----- .woodpecker.yml | 15 ++++++++++++- template.nomad | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 template.nomad diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 66a69e0..a7d6f1c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -15,12 +15,7 @@ builds: - arm archives: - id: archive - name_template: >- - {{ .ProjectName }}_ - {{- if eq .Arch "amd64" }}x86_64 - {{- else if eq .Arch "arm64"}}aarch64 - {{- else if eq .Arch "386" }}i386 - {{- else }}{{ .Arch }}{{ end }} + name_template: "{{ .ProjectName }}-{{ .Arch }}" files: - lure-updater.example.toml blobs: diff --git a/.woodpecker.yml b/.woodpecker.yml index 91bb4f9..3e9e229 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -5,4 +5,17 @@ pipeline: - goreleaser release secrets: [ gitea_token, aws_access_key_id, aws_secret_access_key ] when: - event: tag \ No newline at end of file + event: tag + + deploy: + image: loq9/drone-nomad + secrets: [ github_password, password_hash ] + settings: + addr: http://192.168.100.62:4646 + template: template.nomad + environment: + - PLUGIN_WATCH_DEPLOYMENT=true + - PLUGIN_WATCH_DEPLOYMENT_TIMEOUT=10m + when: + branch: public + event: push \ No newline at end of file diff --git a/template.nomad b/template.nomad new file mode 100644 index 0000000..1b13fb1 --- /dev/null +++ b/template.nomad @@ -0,0 +1,56 @@ +job "lure-updater" { + region = "global" + datacenters = ["dc1"] + type = "service" + + group "site" { + network { + port "webhook" { + to = 8080 + } + } + + task "lure-updater" { + driver = "docker" + + env { + GIT_REPO_DIR="/etc/lure-updater/repo" + GIT_REPO_URL="https://github.com/Elara6331/lure-repo.git" + GIT_CREDENTIALS_USERNAME="lure-repo-bot" + GIT_CREDENTIALS_PASSWORD="${GITHUB_PASSWORD}" + GIT_COMMIT_NAME="lure-repo-bot" + GIT_COMMIT_EMAIL="lure@elara.ws" + WEBHOOK_PASSWORD_HASH="${PASSWORD_HASH}" + + // Hack to force Nomad to re-deploy the service + // instead of ignoring it + COMMIT_SHA = "${DRONE_COMMIT_SHA}" + } + + config { + image = "alpine:latest" + ports = ["webhook"] + volumes = ["local/:/opt/lure-updater:ro"] + command = "/opt/lure-updater/lure-updater" + args = ["-E"] + } + + artifact { + source = "https://api.minio.elara.ws/site/site.tar.gz" + destination = "local/site" + } + + service { + name = "site" + port = "webhook" + + tags = [ + "traefik.enable=true", + "traefik.http.routers.site.rule=Host(`updater.lure.elara.ws`)", + "traefik.http.routers.site.tls.certResolver=letsencrypt", + ] + } + } + } +} +