diff --git a/Justfile b/Justfile index 5687431..82920d1 100644 --- a/Justfile +++ b/Justfile @@ -3,7 +3,10 @@ target := 'main' # Internal endpoint of the Docker registry, where no authentication is necessary registry_url := env_var_or_default('REGISTRY_URL', 'docker.io/') -repo_url := shell("git remote get-url origin | sed 's|git@\\([^:]*\\):\\(.*\\).git|https://\\1/\\2|'") +forgejo_api_key := env_var("FORGEJO_API_KEY") +forgejo_url := shell("git remote get-url origin | sed 's|git@\\([^:]*\\):\\(.*\\).git|https://\\1/\\2|' | cut -d'/' -f-3") +repo_owner := shell("git remote get-url origin | sed 's|git@\\([^:]*\\):\\(.*\\).git|https://\\1/\\2|' | cut -d'/' -f4") +repo_name := shell("git remote get-url origin | sed 's|git@\\([^:]*\\):\\(.*\\).git|https://\\1/\\2|' | cut -d'/' -f5-") pipeline_file := shell('mktemp') @@ -30,7 +33,10 @@ set-pipeline: (make-pipeline pipeline_file) --pipeline {{pipeline_name}} \ --config "{{pipeline_file}}" \ -v registry_url={{registry_url}} \ - -v repo_url={{repo_url}} + -v forgejo_api_key={{forgejo_api_key}} \ + -v forgejo_url={{forgejo_url}} \ + -v repo_owner={{repo_owner}} \ + -v repo_name={{repo_name}} validate: docker run --rm -v ./:/usr/src/app renovate/renovate renovate-config-validator --strict diff --git a/pipelines/build-and-push.yml.j2 b/pipelines/build-and-push.yml.j2 index 2e06255..7c3ef2b 100644 --- a/pipelines/build-and-push.yml.j2 +++ b/pipelines/build-and-push.yml.j2 @@ -1,5 +1,16 @@ {%- import 'jobs/simple-image.yml.j2' as simple_image %} {%- macro simple_image_resource(name, registry_url) -%} + - name: status-{{name}} + type: gitea-status + source: + access_token: ((forgejo_api_key)) + url: ((forgejo_url)) + owner: ((repo_owner)) + name: ((repo_name)) + type: generic + context: build/{{name}} + description: Building image {{name}} + - name: image-{{ name }} type: registry-image icon: docker @@ -15,12 +26,17 @@ resource_types: source: repository: concourse/github-release-resource + - name: gitea-status + type: registry-image + source: + repository: ((registry_url))/gitea-status + resources: - name: repo type: git icon: github source: - uri: ((repo_url)) + uri: ((forgejo_url))/((repo_owner))/((repo_name)) branch: master {%- set registry_url = "((registry_url))" %} @@ -42,3 +58,5 @@ jobs: {{ job.jobs() }} {%- endif %} {% endfor %} + +{# vim: ft=yaml-jinja #} diff --git a/pipelines/jobs/gitea.yml.j2 b/pipelines/jobs/gitea.yml.j2 index 22647a3..c911653 100644 --- a/pipelines/jobs/gitea.yml.j2 +++ b/pipelines/jobs/gitea.yml.j2 @@ -29,6 +29,17 @@ {% endmacro %} {% macro resources(registry_url) -%} + - name: status-gitea + type: gitea-status + source: + access_token: ((forgejo_api_key)) + url: ((forgejo_url)) + owner: ((repo_owner)) + name: ((repo_name)) + type: generic + context: build/gitea + description: Building images gitea-package, gitea-pr, gitea-status + {{ resource('package', registry_url) }} {{ resource('status', registry_url) }} {{ resource('pr', registry_url) }} @@ -37,9 +48,33 @@ {% macro jobs() -%} - name: gitea serial: true + on_success: + put: state-success + resource: status-gitea + no_get: true + params: + state: success + sha: ((.:git_sha)) + + on_failure: + put: state-failure + resource: status-gitea + no_get: true + params: + state: failure + sha: ((.:git_sha)) + plan: - get: repo trigger: true + - load_var: git_sha + file: repo/.git/ref + - put: state-pending + resource: status-gitea + no_get: true + params: + state: pending + sha: ((.:git_sha)) {{ build('package') }} {{ build('status') }} {{ build('pr') }} @@ -50,3 +85,4 @@ {{ put('pr') }} {% endmacro %} +{# vim: ft=yaml-jinja #} diff --git a/pipelines/jobs/rust-xwin.yml.j2 b/pipelines/jobs/rust-xwin.yml.j2 index 71a2c13..1e5b2d1 100644 --- a/pipelines/jobs/rust-xwin.yml.j2 +++ b/pipelines/jobs/rust-xwin.yml.j2 @@ -1,4 +1,15 @@ {% macro resources(registry_url) -%} + - name: status-rust-xwin + type: gitea-status + source: + access_token: ((forgejo_api_key)) + url: ((forgejo_url)) + owner: ((repo_owner)) + name: ((repo_name)) + type: generic + context: build/rust-xwin + description: Building image rust-xwin + - name: image-rust-xwin type: registry-image icon: docker @@ -17,9 +28,33 @@ {% macro jobs() -%} - name: rust-xwin serial: true + on_success: + put: state-success + resource: status-rust-xwin + no_get: true + params: + state: success + sha: ((.:git_sha)) + + on_failure: + put: state-failure + resource: status-rust-xwin + no_get: true + params: + state: failure + sha: ((.:git_sha)) + plan: - get: repo trigger: true + - load_var: git_sha + file: repo/.git/ref + - put: state-pending + resource: status-rust-xwin + no_get: true + params: + state: pending + sha: ((.:git_sha)) - task: build-rust-xwin file: repo/tasks/build-image.yml privileged: true @@ -49,3 +84,5 @@ params: { image: image-rust-xwin-ci/image.tar } no_get: true {% endmacro %} + +{# vim: ft=yaml-jinja #} diff --git a/pipelines/jobs/simple-image.yml.j2 b/pipelines/jobs/simple-image.yml.j2 index 0341f1b..4cfbbb8 100644 --- a/pipelines/jobs/simple-image.yml.j2 +++ b/pipelines/jobs/simple-image.yml.j2 @@ -1,9 +1,33 @@ {% macro jobs(job) -%} - name: {{ job.name }} serial: true + on_success: + put: state-success + resource: status-{{ job.name }} + no_get: true + params: + state: success + sha: ((.:git_sha)) + + on_failure: + put: state-failure + resource: status-{{ job.name }} + no_get: true + params: + state: failure + sha: ((.:git_sha)) + plan: - get: repo trigger: true + - load_var: git_sha + file: repo/.git/ref + - put: state-pending + resource: status-{{ job.name }} + no_get: true + params: + state: pending + sha: ((.:git_sha)) - task: build-image privileged: true file: repo/tasks/build-image.yml @@ -22,3 +46,5 @@ params: { image: image/image.tar } no_get: true {%- endmacro -%} + +{# vim: ft=yaml-jinja #}