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