diff --git a/.tool-versions b/.tool-versions index cc23c20..86b74de 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1,2 @@ deno 2.1.4 +awscli 2.10.0 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2479e6e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM amazon/aws-cli:2.10.0 AS aws +FROM denoland/deno:2.1.4 AS deno + +FROM debian:latest + +COPY --from=deno /usr/bin/deno /usr/bin/deno +COPY --from=aws /usr/local/aws-cli/ /usr/local/aws-cli/ + +ENV PATH="/usr/local/aws-cli/v2/current/bin:${PATH}" + +ENTRYPOINT ["/bin/bash"] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..f036c0b --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,40 @@ +pipeline { + agent none + + options { + disableConcurrentBuilds() + timeout(unit: 'MINUTES', time: 10) + } + + triggers { + cron('0,30 * * * *') + } + + stages { + stage('deploy') { + agent { + dockerfile { + label 'docker' + filename 'Dockerfile' + args "--entrypoint=''" + } + } + environment { + AWS = credentials('adblocker-filters-updater') + SLACK_API_KEY = credentials('c2bd0cc1-529c-4c00-8aa3-c42327175376') + BUNNY_API_KEY = credentials('b3af5886-714c-4ccf-8a5c-db120d60cf18') + AWS_REGION = 'us-east-1' + } + steps { + sh 'deno run config:generate' + // sh 'curl -X POST -H "AccessKey: $BUNNY_API_KEY" "https://api.bunny.net/purge?async=false&url=https%3A%2F%2Fcdn.ghostery.com%2Fadblocker%2Fconfigs%2F%2A"' + // sh 'curl -X POST -H "AccessKey: $BUNNY_API_KEY" "https://api.bunny.net/purge?async=false&url=https%3A%2F%2Fcdn.ghostery.com%2Fadblocker%2F%2A%2Fmetadata.json"' + } + post{ + failure{ + sh 'curl -H "Authorization: Bearer $SLACK_API_KEY" https://slack.com/api/chat.postMessage -d "channel=C03M3895D71" -d "text=JOB FAILED: $JOB_NAME $BUILD_URL"' + } + } + } + } +} diff --git a/deno.json b/deno.json index 40473c9..9511851 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "tasks": { - "config:generate": "deno run --allow-net ./src/config/generate.ts", + "config:generate": "deno run --allow-net --allow-write ./src/config/generate.ts", "build": "deno run -R -W ./src/build.js", "lint": "deno fmt --check ./src ./test", "tests": "deno test --allow-read"