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

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": "negative"
},
},
{
"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,320 +1,345 @@
---
###############################################################################
kind: pipeline
type: docker
name: lint
steps:
- name: Lint Dockerfiles
image: hadolint/hadolint
commands:
- hadolint */Dockerfile*
when:
status:
- failure
- success
platform:
os: linux
arch: amd64
- name: Lint entrypoint scripts
image: koalaman/shellcheck-alpine
commands:
- shellcheck entrypoint*.sh
when:
status:
- failure
- success
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
- pull_request
- push
ref:
exclude:
- refs/heads/renovate/*
- 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
image: plugins/docker
settings:
dockerfile: 1.6/Dockerfile
repo: mwalbeck/getgrav
dry_run: true
- name: build test
image: plugins/docker
settings:
dockerfile: 1.6/Dockerfile
dry_run: true
repo: mwalbeck/getgrav
trigger:
event:
- pull_request
- 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
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"
- name: build test
image: plugins/docker
settings:
dockerfile: 1.6/Dockerfile.prod
dry_run: true
repo: mwalbeck/getgrav
- 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
trigger:
event:
- pull_request
- 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:
- success
- failure
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:
APP_NAME: GRAV
DOCKERFILE_PATH: 1.6/Dockerfile
INCLUDE_MAJOR: negative
VERSION_TYPE: docker_env
- name: build and publish
image: plugins/docker
settings:
dockerfile: 1.6/Dockerfile
password:
from_secret: dockerhub_password
repo: mwalbeck/getgrav
username:
from_secret: dockerhub_username
- 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
when:
status:
- failure
- success
trigger:
branch:
- master
- master
event:
- push
- 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
image: plugins/docker
settings:
dockerfile: 1.6/Dockerfile.prod
repo: mwalbeck/getgrav
dry_run: true
- name: determine tags
image: mwalbeck/determine-docker-tags
environment:
APP_ENV: prod
APP_NAME: GRAV
DOCKERFILE_PATH: 1.6/Dockerfile.prod
INCLUDE_MAJOR: negative
VERSION_TYPE: docker_env
trigger:
event:
- pull_request
- name: build and publish
image: plugins/docker
settings:
dockerfile: 1.6/Dockerfile.prod
password:
from_secret: dockerhub_password
repo: mwalbeck/getgrav
username:
from_secret: dockerhub_username
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
- 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:
- success
- failure
- 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
when:
status:
- failure
- success
trigger:
branch:
- master
- master
event:
- push
- 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
image: plugins/docker
settings:
dockerfile: 1.7/Dockerfile
repo: mwalbeck/getgrav
dry_run: true
- name: determine tags
image: mwalbeck/determine-docker-tags
environment:
APP_NAME: GRAV
CUSTOM_TAGS: latest
DOCKERFILE_PATH: 1.7/Dockerfile
INCLUDE_MAJOR: negative
VERSION_TYPE: docker_env
trigger:
event:
- pull_request
- name: build and publish
image: plugins/docker
settings:
dockerfile: 1.7/Dockerfile
password:
from_secret: dockerhub_password
repo: mwalbeck/getgrav
username:
from_secret: dockerhub_username
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
- 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:
- success
- failure
- 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
when:
status:
- failure
- success
trigger:
branch:
- master
- master
event:
- push
- 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
- name: determine tags
image: mwalbeck/determine-docker-tags
environment:
APP_ENV: prod
APP_NAME: GRAV
CUSTOM_TAGS: latest-prod
DOCKERFILE_PATH: 1.7/Dockerfile.prod
INCLUDE_MAJOR: negative
VERSION_TYPE: docker_env
trigger:
event:
- pull_request
- name: build and publish
image: plugins/docker
settings:
dockerfile: 1.7/Dockerfile.prod
password:
from_secret: dockerhub_password
repo: mwalbeck/getgrav
username:
from_secret: dockerhub_username
depends_on:
- lint
---
###############################################################################
kind: pipeline
type: docker
name: build_and_release_1.7-prod
steps:
- 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"
- 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
- 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:
- success
- failure
- 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
when:
status:
- failure
- success
trigger:
branch:
- master
- master
event:
- push
- push
depends_on:
- lint
- lint
...