-
Notifications
You must be signed in to change notification settings - Fork 1
118 lines (100 loc) · 3.5 KB
/
project-2-deploy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Build image and deploy Prefect flow - Project 2
env:
PROJECT_NAME: project_2
on:
push:
branches:
- stg
- main
paths:
- "project_2/**"
workflow_dispatch:
jobs:
deploy-staging:
name: Deploy to staging
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/stg'
env:
ENVIRONMENT: 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: ${{ secrets.DOCKER_USERNAME }}/${{ env.PROJECT_NAME }}:${{ env.GITHUB_SHA }}-${{ env.ENVIRONMENT }}
run: |
cd $PROJECT_NAME
pip install -r requirements.txt
prefect cloud workspace set -w sales-engineering/sandbox-kevin-stg
prefect deploy --all --prefect-file prefect.yaml
deploy-production:
name: Deploy to production
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
env:
ENVIRONMENT: prod
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 }}-${{ env.ENVIRONMENT }}
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: ${{ secrets.DOCKER_USERNAME }}/${{ env.PROJECT_NAME }}:${{ env.GITHUB_SHA }}-${{ env.ENVIRONMENT }}
run: |
cd $PROJECT_NAME
pip install -r requirements.txt
prefect cloud workspace set -w sales-engineering/sandbox-kevin
prefect deploy --all --prefect-file prefect.yaml