diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..fabbb64e7a3c735d1cf31f27e93b17b7a7071a76 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,35 @@ +include: + # include the component located in the current project from the current SHA + - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/my-component@$CI_COMMIT_SHA + inputs: + stage: build + +stages: [build, test, release] + +# Check if `component job of my-component` is added. +# This example job could also test that the included component works as expected. +# You can inspect data generated by the component, use GitLab API endpoints, or third-party tools. +ensure-job-added: + stage: test + image: badouralix/curl-jq + # Replace "component job of my-component" with the job name in your component. + script: + - | + route="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/jobs" + count=`curl --silent "$route" | jq 'map(select(.name | contains("deploy-dokku"))) | length'` + if [ "$count" != "1" ]; then + exit 1; else + echo "Component Job present" + fi + +# If the pipeline is for a new tag with a semantic version, and all previous jobs succeed, +# create the release. +create-release: + stage: release + image: registry.gitlab.com/gitlab-org/release-cli:latest + script: echo "Creating release $CI_COMMIT_TAG" + rules: + - if: $CI_COMMIT_TAG + release: + tag_name: $CI_COMMIT_TAG + description: "Release $CI_COMMIT_TAG of components repository $CI_PROJECT_PATH" diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..10edfd891ba92f72a1ccab2226b3cef039539b74 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "yaml.schemas": { + "https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json": "file:///home/steel/code/arise/components/dokku/templates/deploy.yml" + } +} \ No newline at end of file diff --git a/templates/deploy.yml b/templates/deploy.yml new file mode 100644 index 0000000000000000000000000000000000000000..4ea206be911030e0157faf90e4feb7d0c661fa5c --- /dev/null +++ b/templates/deploy.yml @@ -0,0 +1,50 @@ +spec: + inputs: + stage: + default: deploy + project: + description: "Le nom du projet Dokku" + when: + default: manual + environment: + default: production + url: + default: "" + image: + description: "L'image Docker à déployer" + default: "" + remote: + description: "L'adresse SSH du serveur Dokku" + default: "ssh://dokku@deploy.runner.iiens.net" +--- +.dokku: + stage: $[[ inputs.stage ]] + when: $[[ inputs.when ]] + image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/dokku/ci-docker-image + variables: + GIT_PUSH_FLAGS: --force + BRANCH: main + GIT_REMOTE_URL: $[[ inputs.remote ]]/$[[ inputs.project ]] + DEPLOY_DOCKER_IMAGE: $[[ inputs.image ]] + script: + - dokku-deploy + after_script: + - dokku-unlock + +deploy-prod: + extends: .dokku + environment: + name: $[[ inputs.environment ]] + url: $[[ inputs.url ]] + action: start + on_stop: stop-prod + +stop-deploy-dokku: + extends: .dokku-stop + environment: + name: $[[ inputs.environment ]] + url: $[[ inputs.url ]] + action: stop + script: + - setup-ssh + - ssh "$[[ inputs.remote ]]" -- ps:stop "$(parse-app-name)"