Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/run-container-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Create Container App Job

on:
workflow_dispatch:
inputs:
python_script:
description: 'The Python script to run'
required: true
default: 'print("Hello from GitHub Actions!")'

jobs:
run-dynamic-script:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Execute dynamic script
run: |
# Create a temporary file and write the input script into it
echo "${{ github.event.inputs.python_script }}" > dynamic_script.py
# Run the script
python3 dynamic_script.py
shell: bash
20 changes: 20 additions & 0 deletions cfa/cloudops/examples/create_container_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import random
import string

from cfa.cloudops import ContainerAppClient

client = ContainerAppClient()
job_name = "my-job"
if not client.check_job_exists(job_name):
client.start_job(
job_name=job_name,
command=["python", "main.py"],
env=[{"name": "APP_MESSAGE", "value": "This is a container app job!"}],
)

characters = string.ascii_letters + string.digits
random_string = "".join(random.choices(characters, k=5))

if client.check_job_exists(job_name):
# Stop a job
client.stop_job(job_name=job_name, job_execution_name=f"{job_name}-{random_string}")
10 changes: 10 additions & 0 deletions cfa/cloudops/examples/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os


def foo():
message = os.getenv("APP_MESSAGE", "Hello from cfa-cloudops!")
return message


if __name__ == "__main__":
print(foo())
Loading