2021-12-22 05:37:15 +00:00
kind : pipeline
type : exec
name : default
steps :
- name : deploy
environment :
PASSWORD :
from_secret : HETZNER_TOKEN
2021-12-23 08:33:50 +00:00
DOMAIN :
from_secret : DOMAIN
2022-01-11 07:49:37 +00:00
2021-12-22 05:37:15 +00:00
commands :
2022-01-11 05:10:22 +00:00
- >
curl -X POST
-H "Authorization: Bearer $PASSWORD"
-H "Content-Type: application/json"
-d '{"name":"ci-sibling","server_type":"cx11","start_after_create":true,"image":"ubuntu-20.04", "volumes":[], "networks":[], "user_data":"#cloud-config\\nruncmd:\\n- curl https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-infect/raw/branch/rolling-testing/nixos-infect | PROVIDER=hetzner NIX_CHANNEL=nixos-21.05 DOMAIN=ruleit.stream LUSER=cicdcicd PASSWORD=cicdcicdpass CF_TOKEN=228337 DB_PASSWORD=228337 API_TOKEN=228337 HOSTNAME=ruleit.stream bash 2>&1 | tee /tmp/infect.log","labels":{},"automount":false, "location":"fsn1"}'
'https://api.hetzner.cloud/v1/servers'
2021-12-23 08:33:50 +00:00
- name : dns
2022-01-11 05:27:10 +00:00
environment :
PASSWORD :
from_secret : HETZNER_TOKEN
CLOUDFLARE_TOKEN :
from_secret : CLOUDFLARE_TOKEN
2022-01-11 13:12:33 +00:00
DOMAIN : ruleit.stream
2022-01-11 05:27:10 +00:00
ZONE_ID :
from_secret : ZONE_ID
2022-01-11 08:14:22 +00:00
2021-12-23 08:33:50 +00:00
commands :
2022-01-11 12:55:47 +00:00
- >
2022-01-11 12:57:36 +00:00
curl -s -H "Authorization: Bearer $PASSWORD" 'https://api.hetzner.cloud/v1/servers' > .machine.json
2022-01-11 12:55:47 +00:00
- >
2022-01-11 13:47:06 +00:00
export machineip=$( for i in {0..24}; do jq 'if .servers['$i'].name == "ci-sibling" then .servers['$i'].public_net.ipv4.ip else null end' .machine.json; done | grep -v null | sed 's/"//' | sed 's/"//' )
2022-01-11 13:03:30 +00:00
- echo $machineip
2022-01-11 05:10:22 +00:00
- >
2022-01-11 05:34:04 +00:00
curl -s -X GET "https://api.cloudflare.com/client/v4/zones?name=$DOMAIN"
-H "Authorization: Bearer $CLOUDFLARE_TOKEN"
2022-01-11 05:10:22 +00:00
-H "Content-Type: application/json"
- >
2022-01-11 14:07:03 +00:00
curl -s -X POST "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records"
2022-01-11 05:34:04 +00:00
-H "Authorization: Bearer $CLOUDFLARE_TOKEN"
2022-01-11 05:10:22 +00:00
-H "Content-Type: application/json"
2022-01-11 13:47:06 +00:00
--data '{"type":"A","name":"@","content":"'"$$machineip"'","ttl":3600,"priority":10,"proxied":false}'
2022-01-11 05:10:22 +00:00
- >
2022-01-11 05:44:26 +00:00
curl -s -X POST "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records"
-H "Authorization: Bearer $CLOUDFLARE_TOKEN"
2022-01-11 05:10:22 +00:00
-H "Content-Type: application/json"
2022-01-11 14:01:23 +00:00
--data '{"type":"MX","name":"@","content":"'"$$DOMAIN"'","ttl":3600,"priority":10,"proxied":false}'
2022-01-11 05:10:22 +00:00
- >
2022-01-11 05:44:26 +00:00
curl -s -X POST "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records"
-H "Authorization: Bearer $CLOUDFLARE_TOKEN"
2022-01-11 05:10:22 +00:00
-H "Content-Type: application/json"
--data '{"type":"TXT","name":"_dmarc","content":"v=DMARC1; p=none","ttl":18000,"priority":10,"proxied":false}'
- >
2022-01-11 05:44:26 +00:00
curl -s -X POST "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records"
-H "Authorization: Bearer $CLOUDFLARE_TOKEN"
2022-01-11 05:10:22 +00:00
-H "Content-Type: application/json"
2022-01-11 14:01:23 +00:00
--data '{"type":"TXT","name":"'"$$DOMAIN"'","content":"v=spf1 a mx ip4:"$$machineip" -all","ttl":18000,"priority":10,"proxied":false}'
2021-12-22 06:16:02 +00:00
- name : sleep
commands :
- sleep 360
- name : test
commands :
2022-01-11 05:10:22 +00:00
- >
curl -H "Authorization: Bearer 228337" 'https://api.ruleit.stream/services/status'
- >
2022-01-17 05:00:27 +00:00
swaks --to ci@ruleit.stream -s selfprivacy.org -tls -au test@selfprivacy.org -ap 228337
2022-01-11 05:10:22 +00:00
- >
curl --user admin:228337 https://cloud.ruleit.stream/ocs/v2.php/apps/serverinfo/api/v1/info?format=json
- echo "blah-blah" > file
- >
curl -T file -u admin:228337 https://cloud.ruleit.stream/remote.php/dav/files/admin/file
- >
2022-01-12 05:06:16 +00:00
curl -u admin:228337 https://cloud.ruleit.stream/remote.php/dav/files/admin/file
- name : teardown
2022-01-12 05:13:51 +00:00
environment :
PASSWORD :
from_secret : HETZNER_TOKEN
CLOUDFLARE_TOKEN :
from_secret : CLOUDFLARE_TOKEN
DOMAIN : ruleit.stream
ZONE_ID :
from_secret : ZONE_ID
2022-01-12 05:06:16 +00:00
commands :
- >
2022-01-12 05:16:15 +00:00
curl -s "https://api.hetzner.cloud/v1/servers"
-H "Authorization: Bearer $PASSWORD" > .hetzner_servers.json
2022-01-12 05:06:16 +00:00
- export machineid=$( for i in {0..24}; do jq 'if .servers['$i'].name == "ci-sibling" then .servers['$i'].id else null end' .hetzner_servers.json; done | grep -v null | sed 's/"//g')
- >
2022-01-12 05:16:15 +00:00
curl -s -X DELETE "https://api.hetzner.cloud/v1/servers/$machineid"
2022-01-17 07:11:29 +00:00
-H "Authorization: Bearer $PASSWORD"
2022-01-19 20:58:37 +00:00
---
kind : pipeline
type : docker
name : notify
steps :
- name : notify
image : drillster/drone-email
2022-01-19 21:15:59 +00:00
settings :
2022-01-19 21:17:12 +00:00
from.address : test@selfprivacy.org
2022-01-19 21:15:59 +00:00
from.name : SelfPrivacy CI
host : selfprivacy.org
2022-01-20 05:09:55 +00:00
username : test@selfprivacy.org
2022-01-19 21:15:59 +00:00
password : 228337
2022-01-21 04:57:15 +00:00
recipients_only : false
2022-01-21 04:50:28 +00:00
subject : Daily build results
body : >
[ {{ build.status }}]
{{ repo.owner }}/{{ repo.name }}
2022-01-21 04:53:19 +00:00
({{ build.branch }} - {{ truncate build.commit 8 }})