-
Notifications
You must be signed in to change notification settings - Fork 13
74 lines (73 loc) · 2.69 KB
/
cd-staging.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
---
name: Register flows (staging)
on:
pull_request:
branches: [main]
paths:
- .github/workflows/cd_staging.yaml
- pipelines/**/*
- pyproject.toml
- Dockerfile
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
GH_PAT: ${{ secrets.GH_PAT }}
GKE_CLUSTER: ${{ secrets.GKE_CLUSTER_NAME }}
GKE_ZONE: ${{ secrets.GKE_ZONE }}
IMAGE_NAME: ghcr.io/basedosdados/prefect-flows
PREFECT__BACKEND: cloud
PREFECT__CLOUD__API: https://prefect.basedosdados.org/api
PREFECT__CLOUD__PORT: 443
PREFECT__SERVER__PROJECT: ${{ secrets.PREFECT__SERVER__PROJECT__STAGING }}
PREFECT_AUTH_TOML: ${{ secrets.PREFECT_AUTH_TOML }}
VAULT_ADDRESS: https://vault.basedosdados.org/
VAULT_TOKEN: ${{ secrets.VAULT_TOKEN }}
jobs:
build-container:
if: startsWith(github.head_ref, 'staging/')
name: Register flows (staging)
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up poetry
run: pipx install poetry
- name: Set up python
uses: actions/setup-python@v4
with:
cache: poetry
python-version: '3.10'
- name: Setup Google Cloud CLI
uses: google-github-actions/[email protected]
with:
service_account_key: ${{ secrets.GCP_SA_KEY }}
project_id: ${{ secrets.GCP_PROJECT_ID }}
export_default_credentials: true
- name: Install Python dependencies for deploying
run: |-
poetry install --with=dev
- name: Update image tag in constants
run: |-
poetry run python .github/workflows/scripts/replace_docker_tag.py $IMAGE_NAME $GITHUB_SHA
- name: Get changed files for code tree analysis
id: files
uses: Ana06/[email protected]
- name: Perform code tree analysis
id: code-tree-analysis
continue-on-error: true
run: |
poetry run python .github/workflows/scripts/code_tree_analysis.py "${{ steps.files.outputs.all }}" --write-to-file
- name: Write auth.toml
run: |-
mkdir -p $HOME/.prefect
echo $PREFECT_AUTH_TOML | base64 --decode > $HOME/.prefect/auth.toml
- name: Wait for Docker image to be available
uses: lewagon/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
check-name: Build Docker image
repo-token: ${{ secrets.GITHUB_TOKEN }}
verbose: true
- name: Register Prefect flows
run: |-
poetry run python .github/workflows/scripts/register_flows.py --project $PREFECT__SERVER__PROJECT --path pipelines/ --no-schedule --filter-affected-flows