-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
10e077f
commit a9efb9a
Showing
6 changed files
with
155 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
name: Build image and deploy Prefect flow - Project 1 | ||
|
||
env: | ||
PROJECT_NAME: project_1 | ||
|
||
on: | ||
push: | ||
branches: | ||
- stg | ||
- main | ||
paths: | ||
- "project_1/**" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy-staging: | ||
name: Deploy to staging | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/stg' | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Get commit hash | ||
id: get-commit-hash | ||
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" | ||
|
||
- name: Build and push | ||
id: build-docker-image | ||
env: | ||
GITHUB_SHA: ${{ steps.get-commit-hash.outputs.COMMIT_HASH }} | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ${{ env.PROJECT_NAME }}/ | ||
push: true | ||
tags: ${{ secrets.DOCKER_USERNAME }}/${{ env.PROJECT_NAME }}:${{ env.GITHUB_SHA }}-stg | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.11" | ||
cache: "pip" | ||
|
||
- name: Prefect Deploy | ||
env: | ||
PREFECT_API_KEY: ${{ secrets.PREFECT_API_KEY }} | ||
IMAGE_NAME: ${{ steps.build-docker-image.outputs.metadata.image.name }} | ||
run: | | ||
pip install -r $PROJECT_NAME/requirements.txt | ||
prefect cloud workspace set -w sales-engineering/sandbox-kevin-stg | ||
prefect deploy --all --prefect-file $PROJECT_NAME/prefect.yaml | ||
deploy-production: | ||
name: Deploy to production | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/main' | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Get commit hash | ||
id: get-commit-hash | ||
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" | ||
|
||
- name: Build and push | ||
id: build-docker-image | ||
env: | ||
GITHUB_SHA: ${{ steps.get-commit-hash.outputs.COMMIT_HASH }} | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ${{ env.PROJECT_NAME }}/ | ||
push: true | ||
tags: ${{ secrets.DOCKER_USERNAME }}/${{ env.PROJECT_NAME }}:${{ env.GITHUB_SHA }}-prod | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.11" | ||
cache: "pip" | ||
|
||
- name: Prefect Deploy | ||
env: | ||
PREFECT_API_KEY: ${{ secrets.PREFECT_API_KEY }} | ||
IMAGE_NAME: ${{ steps.build-docker-image.outputs.metadata.image.name }} | ||
run: | | ||
pip install -r $PROJECT_NAME/requirements.txt | ||
prefect cloud workspace set -w sales-engineering/sandbox-kevin | ||
prefect deploy --all --prefect-file $PROJECT_NAME/prefect.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM --platform=linux/amd64 prefecthq/prefect:2.16.2-python3.11 | ||
COPY requirements.txt requirements.txt | ||
RUN pip install -r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from prefect import flow | ||
|
||
|
||
@flow(log_prints=True) | ||
def hello(): | ||
print("Hello from Project 1!") | ||
|
||
|
||
if __name__ == "__main__": | ||
hello() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: cicd-example-workspaces | ||
prefect-version: 2.16.2 | ||
|
||
build: null | ||
|
||
push: | ||
- prefect_aws.deployments.steps.push_to_s3: | ||
requires: prefect-aws | ||
bucket: cicd-example-workspaces | ||
folder: "{{ $PROJECT_NAME }}" | ||
credentials: "{{ prefect.blocks.aws-credentials.ecs-worker-changes }}" | ||
|
||
pull: | ||
- prefect_aws.deployments.steps.pull_from_s3: | ||
requires: prefect-aws | ||
bucket: cicd-example-workspaces | ||
folder: "{{ $PROJECT_NAME }}" | ||
credentials: "{{ prefect.blocks.aws-credentials.ecs-worker-changes }}" | ||
|
||
deployments: | ||
- name: my-project-1-deployment | ||
entrypoint: "{{ $PROJECT_NAME }}/flow.py:hello" | ||
work_pool: | ||
name: k8s-demo | ||
work_queue_name: default | ||
job_variables: | ||
image: "{{ $IMAGE_NAME }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
prefect==2.16.1 | ||
prefect-aws |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters