Add starlark #87

Merged
mwalbeck merged 2 commits from issues/85/1 into master 2021-02-16 14:51:44 +00:00
2 changed files with 419 additions and 242 deletions
Showing only changes of commit fccf347595 - Show all commits

152
.drone.star Normal file
View File

@ -0,0 +1,152 @@
def main(ctx):
return [
lint(),
default_tests("1.6", "1.6"),
default_tests("1.6-prod", "1.6", "Dockerfile.prod"),
default_tests("1.7", "1.7"),
default_tests("1.7-prod", "1.7", "Dockerfile.prod"),
release("1.6", "1.6"),
release("1.6-prod", "1.6", "Dockerfile.prod", "prod"),
release("1.7", "1.7", custom_tags="latest"),
release("1.7-prod", "1.7", "Dockerfile.prod", "prod", "latest-prod"),
]
def lint():
return {
"kind": "pipeline",
"type": "docker",
"name": "lint",
"steps": [
{
"name": "Lint Dockerfiles",
"image": "hadolint/hadolint",
"commands": [
"hadolint */Dockerfile*"
],
"when": {
"status": [
"failure",
"success"
]
}
},
{
"name": "Lint entrypoint scripts",
"image": "koalaman/shellcheck-alpine",
"commands": [
"shellcheck entrypoint*.sh"
],
"when": {
"status": [
"failure",
"success"
]
}
}
],
"trigger": {
"event": [
"pull_request",
"push"
],
"ref": {
"exclude": [
"refs/heads/renovate/*"
]
}
}
}
def default_tests(name, grav_version, dockerfile="Dockerfile"):
return {
"kind": "pipeline",
"type": "docker",
"name": "default_tests_%s" % name,
"steps": [
{
"name": "build test",
"image": "plugins/docker",
"settings": {
"dockerfile": "%s/%s" % (grav_version, dockerfile),
"dry_run": "true",
"repo": "mwalbeck/getgrav"
},
}
],
"trigger": {
"event": [
"pull_request"
]
},
"depends_on": [
"lint"
]
}
def release(name, grav_version, dockerfile="Dockerfile", app_env="", custom_tags="",):
return {
"kind": "pipeline",
"type": "docker",
"name": "release_%s" % name,
"steps": [
{
"name": "determine tags",
"image": "mwalbeck/determine-docker-tags",
"environment": {
"VERSION_TYPE": "docker_env",
"APP_NAME": "GRAV",
"DOCKERFILE_PATH": "%s/%s" % (grav_version, dockerfile),
"APP_ENV": app_env,
"CUSTOM_TAGS": custom_tags,
"INCLUDE_MAJOR": "no"
},
},
{
"name": "build and publish",
"image": "plugins/docker",
"settings": {
"dockerfile": "%s/%s" % (grav_version, dockerfile),
"username": {
"from_secret": "dockerhub_username"
},
"password": {
"from_secret": "dockerhub_password"
},
"repo": "mwalbeck/getgrav"
},
},
{
"name": "notify",
"image": "plugins/matrix",
"settings": {
"homeserver": "https://matrix.mwalbeck.org",
"roomid": {
"from_secret": "matrix_roomid"
},
"username": {
"from_secret": "matrix_username"
},
"password": {
"from_secret": "matrix_password"
}
},
"when": {
"status": [
"failure",
"success"
]
}
}
],
"trigger": {
"branch": [
"master"
],
"event": [
"push"
]
},
"depends_on": [
"lint"
]
}

View File

@ -1,11 +1,14 @@
---
###############################################################################
kind: pipeline
type: docker
name: lint
platform:
os: linux
arch: amd64
steps:
- name: Lint Dockerfiles
- name: Lint Dockerfiles
image: hadolint/hadolint
commands:
- hadolint */Dockerfile*
@ -14,7 +17,7 @@ steps:
- failure
- success
- name: Lint entrypoint scripts
- name: Lint entrypoint scripts
image: koalaman/shellcheck-alpine
commands:
- shellcheck entrypoint*.sh
@ -32,67 +35,143 @@ trigger:
- refs/heads/renovate/*
---
###############################################################################
kind: pipeline
type: docker
name: test_1.6
name: default_tests_1.6
platform:
os: linux
arch: amd64
steps:
- name: build test
- name: build test
image: plugins/docker
settings:
dockerfile: 1.6/Dockerfile
repo: mwalbeck/getgrav
dry_run: true
repo: mwalbeck/getgrav
trigger:
event:
- pull_request
depends_on:
- lint
- lint
---
###############################################################################
kind: pipeline
type: docker
name: build_and_release_1.6
name: default_tests_1.6-prod
platform:
os: linux
arch: amd64
steps:
- name: determine tags
- name: build test
image: plugins/docker
settings:
dockerfile: 1.6/Dockerfile.prod
dry_run: true
repo: mwalbeck/getgrav
trigger:
event:
- pull_request
depends_on:
- lint
---
kind: pipeline
type: docker
name: default_tests_1.7
platform:
os: linux
arch: amd64
steps:
- name: build test
image: plugins/docker
settings:
dockerfile: 1.7/Dockerfile
dry_run: true
repo: mwalbeck/getgrav
trigger:
event:
- pull_request
depends_on:
- lint
---
kind: pipeline
type: docker
name: default_tests_1.7-prod
platform:
os: linux
arch: amd64
steps:
- name: build test
image: plugins/docker
settings:
dockerfile: 1.7/Dockerfile.prod
dry_run: true
repo: mwalbeck/getgrav
trigger:
event:
- pull_request
depends_on:
- lint
---
kind: pipeline
type: docker
name: release_1.6
platform:
os: linux
arch: amd64
steps:
- name: determine tags
image: mwalbeck/determine-docker-tags
environment:
VERSION_TYPE: "docker_env"
APP_NAME: "GRAV"
DOCKERFILE_PATH: "1.6/Dockerfile"
APP_ENV: ""
CUSTOM_TAGS: ""
INCLUDE_MAJOR: "no"
APP_NAME: GRAV
DOCKERFILE_PATH: 1.6/Dockerfile
INCLUDE_MAJOR: no
VERSION_TYPE: docker_env
- name: build and publish
- name: build and publish
image: plugins/docker
settings:
dockerfile: 1.6/Dockerfile
username:
from_secret: dockerhub_username
password:
from_secret: dockerhub_password
repo: mwalbeck/getgrav
username:
from_secret: dockerhub_username
- name: notify
- name: notify
image: plugins/matrix
settings:
homeserver: https://matrix.mwalbeck.org
password:
from_secret: matrix_password
roomid:
from_secret: matrix_roomid
username:
from_secret: matrix_username
password:
from_secret: matrix_password
when:
status:
- success
- failure
- success
trigger:
branch:
@ -101,70 +180,51 @@ trigger:
- push
depends_on:
- lint
- lint
---
###############################################################################
kind: pipeline
type: docker
name: test_1.6-prod
name: release_1.6-prod
platform:
os: linux
arch: amd64
steps:
- name: build test
- name: determine tags
image: mwalbeck/determine-docker-tags
environment:
APP_ENV: prod
APP_NAME: GRAV
DOCKERFILE_PATH: 1.6/Dockerfile.prod
INCLUDE_MAJOR: no
VERSION_TYPE: docker_env
- name: build and publish
image: plugins/docker
settings:
dockerfile: 1.6/Dockerfile.prod
repo: mwalbeck/getgrav
dry_run: true
trigger:
event:
- pull_request
depends_on:
- lint
---
###############################################################################
kind: pipeline
type: docker
name: build_and_release_1.6-prod
steps:
- name: determine tags
image: mwalbeck/determine-docker-tags
environment:
VERSION_TYPE: "docker_env"
APP_NAME: "GRAV"
DOCKERFILE_PATH: "1.6/Dockerfile.prod"
APP_ENV: "prod"
CUSTOM_TAGS: ""
INCLUDE_MAJOR: "no"
- name: build and publish
image: plugins/docker
settings:
dockerfile: 1.6/Dockerfile.prod
username:
from_secret: dockerhub_username
password:
from_secret: dockerhub_password
repo: mwalbeck/getgrav
username:
from_secret: dockerhub_username
- name: notify
- name: notify
image: plugins/matrix
settings:
homeserver: https://matrix.mwalbeck.org
password:
from_secret: matrix_password
roomid:
from_secret: matrix_roomid
username:
from_secret: matrix_username
password:
from_secret: matrix_password
when:
status:
- success
- failure
- success
trigger:
branch:
@ -173,70 +233,51 @@ trigger:
- push
depends_on:
- lint
- lint
---
###############################################################################
kind: pipeline
type: docker
name: test_1.7
name: release_1.7
platform:
os: linux
arch: amd64
steps:
- name: build test
- name: determine tags
image: mwalbeck/determine-docker-tags
environment:
APP_NAME: GRAV
CUSTOM_TAGS: latest
DOCKERFILE_PATH: 1.7/Dockerfile
INCLUDE_MAJOR: no
VERSION_TYPE: docker_env
- name: build and publish
image: plugins/docker
settings:
dockerfile: 1.7/Dockerfile
repo: mwalbeck/getgrav
dry_run: true
trigger:
event:
- pull_request
depends_on:
- lint
---
###############################################################################
kind: pipeline
type: docker
name: build_and_release_1.7
steps:
- name: determine tags
image: mwalbeck/determine-docker-tags
environment:
VERSION_TYPE: "docker_env"
APP_NAME: "GRAV"
DOCKERFILE_PATH: "1.7/Dockerfile"
APP_ENV: ""
CUSTOM_TAGS: "latest"
INCLUDE_MAJOR: "no"
- name: build and publish
image: plugins/docker
settings:
dockerfile: 1.7/Dockerfile
username:
from_secret: dockerhub_username
password:
from_secret: dockerhub_password
repo: mwalbeck/getgrav
username:
from_secret: dockerhub_username
- name: notify
- name: notify
image: plugins/matrix
settings:
homeserver: https://matrix.mwalbeck.org
password:
from_secret: matrix_password
roomid:
from_secret: matrix_roomid
username:
from_secret: matrix_username
password:
from_secret: matrix_password
when:
status:
- success
- failure
- success
trigger:
branch:
@ -245,70 +286,52 @@ trigger:
- push
depends_on:
- lint
- lint
---
###############################################################################
kind: pipeline
type: docker
name: test_1.7-prod
name: release_1.7-prod
platform:
os: linux
arch: amd64
steps:
- name: build test
image: plugins/docker
settings:
dockerfile: 1.7/Dockerfile.prod
repo: mwalbeck/getgrav
dry_run: true
trigger:
event:
- pull_request
depends_on:
- lint
---
###############################################################################
kind: pipeline
type: docker
name: build_and_release_1.7-prod
steps:
- name: determine tags
- name: determine tags
image: mwalbeck/determine-docker-tags
environment:
VERSION_TYPE: "docker_env"
APP_NAME: "GRAV"
DOCKERFILE_PATH: "1.7/Dockerfile.prod"
APP_ENV: "prod"
CUSTOM_TAGS: "latest-prod"
INCLUDE_MAJOR: "no"
APP_ENV: prod
APP_NAME: GRAV
CUSTOM_TAGS: latest-prod
DOCKERFILE_PATH: 1.7/Dockerfile.prod
INCLUDE_MAJOR: no
VERSION_TYPE: docker_env
- name: build and publish
- name: build and publish
image: plugins/docker
settings:
dockerfile: 1.7/Dockerfile.prod
username:
from_secret: dockerhub_username
password:
from_secret: dockerhub_password
repo: mwalbeck/getgrav
username:
from_secret: dockerhub_username
- name: notify
- name: notify
image: plugins/matrix
settings:
homeserver: https://matrix.mwalbeck.org
password:
from_secret: matrix_password
roomid:
from_secret: matrix_roomid
username:
from_secret: matrix_username
password:
from_secret: matrix_password
when:
status:
- success
- failure
- success
trigger:
branch:
@ -317,4 +340,6 @@ trigger:
- push
depends_on:
- lint
- lint
...