Skip to main content

Deploy a Demo Worker Script

The easiest way to deploy an automation is to provide a Python worker script via a Git repository, preferably on GitHub.

Worker scripts will be cloned from the repo when running the worker as a job. To accomplish this a repo url, credentials and a ssh key need to be specified when creating a worker entity in the //bench Cloud Automation Framework.

info

As an additional prerequisite for this demo you will need to have a (free) account on GitHub

Create a Worker Script

Fork the worker script demo from the tycho//works git repository [email protected]/tycho-works/twb-workerscript-demo.git:

  1. Sign-in to GitHub

  2. Enter repo:tycho-works/twb-workerscript-demo in the searchbar to find the demo repository.

  3. Click on the Fork button on the right side.

    You will find the following files in your newly created repo:

    schemas.json          # input/output schemas specification
    worker_script.py # python script handling the automation

    Inspect and modify the files if you like. You will need nothing more that a git repo for creating an automation worker.

  4. Click on the green <> Code button in the middle and select the SSH tab.

    You can copy the path of your repo fork here. It should look like [email protected]:<your-github-name>/twb-workerscript-demo.

Create a Worker Entity

To deploy the worker script in the Automation Framework follow these steps:

  1. Sign-in to //bench Automation Framework.

  2. Click on the "WORKERS" section on the left menu.

  3. Click on the purple "+" icon in the lower right to open the worker creation dialog.

  4. Fill out the following fields:

    • "Name" of your script, e.g. Script Demo
    • "Description" of your script (optional)
    • "Address" as europe.pkg.dev/twb-worker-pygit which is the address of a pre-defined tycho//works worker docker image executing a python script from a Git repo.
    • "Tag" which should be 1.0.1 for the fixed version (preferred) or main for the latest version of this pre-defined worker.
    • "Script worker" checked to be able to enter further details.
  5. Click on the "CREATE" button to create a new worker entity which can execute a python script.

  6. To attach your Python script of your Git repo click on the three dots icon menu in the row of created worker. Click on the "Edit" menu item.

  7. Now, additional fields appear to be filled out because this worker is a "Script worker":

    • "GIT repository" which is the git repo path of your python script as [email protected]:<your-github-name>/twb-workerscript-demo
    • "Branch name" as main referring to the branch to be checked out when executing the script.
    • "SSH public key" which is pre-filled out to be used for accessing your GitHub script repository.
    • "SSH private key" which is pre-filled out as the complementary part of the public key.
    • "SSH phrase" is currently empty.
  8. Click on the "SAVE" button to update these details.

  9. Now you need to enable GitHub to let the Automation Framework access (clone) the worker script repo by SSH:

    • Click on GitHub add a new public key.

    • Add a "Title" for your SSH Key like bench worker script demo

    • Leave "Key type" selected on "Authentication Key"

    • Copy-and-Paste the "SSH public key" from step 7. into the "Key" field. (You may either click on "Edit" or "Details" to open up the worker details to copy the SSH public key)

    • Click on the green Add SSH key button.

  10. Done!

Configure the Demo Task

xx

Run the Demo Job

yy