diff --git a/.conducto.cfg b/.conducto.cfg new file mode 100644 index 0000000..e38369d --- /dev/null +++ b/.conducto.cfg @@ -0,0 +1,17 @@ +# The .conducto.cfg file defines how and when to trigger a CI/CD pipeline. +# Each section defines a command that is launches a pipeline. +# You can trigger a pipeline on pull request and branch push events. + + +# This section launches a pipeline on every Pull Request. +[pr] +command = python pipeline.py pr --branch={branch} + + +# Uncomment this section to trigger the "deploy" pipeline whenever the "main" +# branch is updated. If the slack integation is installed, the slack_channel +# will automatically receive useful updates as the pipeline runs. +; [push production] +; filter = {branch} == main +; command = python pipeline.py deploy +; slack_channel = github-deploy diff --git a/pipeline.py b/pipeline.py new file mode 100644 index 0000000..8f7ebea --- /dev/null +++ b/pipeline.py @@ -0,0 +1,26 @@ +# Define your CI/CD pipeline in a Python script. + +import conducto as co + + +# `pr()` creates and returns a CI/CD pipeline for a Pull Request. Run from the command +# line with `python pipeline.py pr --branch=`. +def pr(branch) -> co.Parallel: + # Make a Docker image, based on python:alpine, with the whole repo and the contents + # of the given branch. + image = co.Image("python:alpine", copy_repo=True, copy_branch=branch) + + # Using that Docker image, run three commands in parallel to interact with the + # repo's files. + with co.Parallel(image=image) as root: + co.Exec(f"echo {branch}", name="print branch") + co.Exec("pwd", name="print working directory") + co.Exec("ls -la", name="list files") + + co.git.apply_status_all(root) + + return root + + +if __name__ == "__main__": + co.main()