Simple repository with GitHub Actions workflow (based on Prefect base image) for a single flow with S3 storage

The simplest GitHub action for Cloud 2.0:

name: CI
on:
  push:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    container: prefecthq/prefect:2-python3.9
    env:
      API_KEY: ${{ secrets.PREFECT_API_KEY}}
    steps:
      - uses: actions/checkout@v3
      - name: Login to Prefect Cloud 2.0
        run: prefect cloud login --key $API_KEY --workspace 'annaprefect/prod'
      - name: Check Prefect version
        run: prefect version
      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - name: Create deployment
        run: prefect deployment build flows/hello_flow.py:hello_flow -a -n dev -q dev -ib ecs-task/dev -sb github/dev

Example flows/hello_flow.py:

import platform
from prefect import task, flow
from prefect import get_run_logger
from prefect.deployments import DeploymentSpec


@task
def say_hi():
    logger = get_run_logger()
    logger.info("Hello world!")


@task
def print_platform_info():
    logger = get_run_logger()
    logger.info(
        "Platform information: IP = %s, Python = %s, Platform type = %s, System Version = %s",
        platform.node(),
        platform.python_version(),
        platform.platform(),
        platform.version(),
    )


@flow
def hello_flow():
    say_hi()
    print_platform_info()

if __name__ == "__main__":
    hello_flow()
1 Like