From da4fdf78fb6e98b36ddb4303021c51783d642269 Mon Sep 17 00:00:00 2001 From: Jonathan Giroux Date: Fri, 4 Oct 2024 02:10:26 +0200 Subject: [PATCH] ci: add Concourse pipelines --- .gitattributes | 4 +- .gitignore | 5 +- concourse.jsonnet | 133 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 concourse.jsonnet diff --git a/.gitattributes b/.gitattributes index 6923ea2..d1f35c6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,5 @@ +/concourse.jsonnet eol=lf + # https://gitattributes.io/api/web # Content @@ -73,4 +75,4 @@ *.eot binary *.otf binary *.woff binary -*.woff2 binary \ No newline at end of file +*.woff2 binary diff --git a/.gitignore b/.gitignore index 63908d9..88414f6 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,7 @@ public .log # macOS related files -.DS_Store \ No newline at end of file +.DS_Store + +# CICD +/.concourse diff --git a/concourse.jsonnet b/concourse.jsonnet new file mode 100644 index 0000000..9c5bbaf --- /dev/null +++ b/concourse.jsonnet @@ -0,0 +1,133 @@ +local GITEA_CREDENTIALS = { + password: '((gitea-access-token))', + username: 'concourse', +}; +local GITEA_HOST = 'gitea.cookie.paris'; + +local DOCKER_IMAGE_RESOURCE = { + name: 'docker-image', + source: GITEA_CREDENTIALS { + repository: GITEA_HOST + '/collective/ccc-website', + tag: 'latest', + }, + type: 'registry-image', +}; + +local GIT_REPOSITORY_RESOURCE = { + name: 'git-repository', + source: { + uri: 'https://github.com/CookieCollective/ccc-website.git', + }, + type: 'git', +}; + +local BUILD_DOCKER_IMAGE_TASK = { + caches: [ + { + path: 'cache', + }, + ], + image_resource: { + source: { + repository: 'concourse/oci-build-task', + }, + type: 'registry-image', + }, + inputs: [ + { + name: GIT_REPOSITORY_RESOURCE.name, + path: '.', + }, + ], + outputs: [ + { + name: 'image', + }, + ], + platform: 'linux', + run: { + path: 'build', + }, +}; + +{ + 'pipelines-main.json': { + jobs: [ + { + local JSONNET_OUTPUT = '.concourse', + name: 'update-pipelines', + plan: [ + { + get: GIT_REPOSITORY_RESOURCE.name, + trigger: true, + }, + { + task: 'generate-concourse-files', + config: { + image_resource: { + source: { + repository: 'bitnami/jsonnet', + }, + type: 'registry-image', + }, + inputs: [ + { + name: GIT_REPOSITORY_RESOURCE.name, + }, + ], + outputs: [ + { + name: 'concourse', + }, + ], + platform: 'linux', + run: { + args: [ + '-m', + JSONNET_OUTPUT, + GIT_REPOSITORY_RESOURCE.name + '/concourse.jsonnet', + ], + path: 'jsonnet', + user: 'root', + }, + }, + }, + { + file: JSONNET_OUTPUT + '/pipelines-main.json', + set_pipeline: 'ccc-website', + }, + ], + public: true, + }, + { + name: 'build', + plan: [ + { + get: GIT_REPOSITORY_RESOURCE.name, + passed: [ + 'update-pipelines', + ], + trigger: true, + }, + { + config: BUILD_DOCKER_IMAGE_TASK, + privileged: true, + task: 'build-docker-image', + }, + { + put: DOCKER_IMAGE_RESOURCE.name, + params: { + image: 'image/image.tar', + }, + }, + ], + public: true, + }, + ], + resources: [ + DOCKER_IMAGE_RESOURCE, + GIT_REPOSITORY_RESOURCE, + ], + }, + 'tasks-build-docker-image.json': BUILD_DOCKER_IMAGE_TASK, +}