Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed auto update from airflow variables #226

Merged
merged 25 commits into from
Oct 27, 2023
Merged
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
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ jobs:
GOOGLE_CLOUD_PROJECT: test-hubble-319619
BUCKET: us-central1-hubble-1pt5-dev-7db0e004-bucket

- name: Update Airflow variables
uses: actions-hub/gcloud@master
env:
PROJECT_ID: test-hubble-319619
APPLICATION_CREDENTIALS: "${{ secrets.CREDS_TEST_HUBBLE }}"
COMPOSER_ENVIRONMENT: hubble-1pt5-dev
LOCATION: us-central1
with:
args: >
components install kubectl && gcloud composer environments run
$COMPOSER_ENVIRONMENT --location $LOCATION variables import
-- gcsfuse/variables.json

promote-to-prod:
runs-on: ubuntu-latest
# deploy only occurs when pr is merged
Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

- name: Install dependencies
run: |
cat airflow_variables.json | sed -e s/\\/home\\/airflow\\/gcs\\/dags\\/// > airflow_variables_ci.json
cat airflow_variables_prod.json | sed -e s/\\/home\\/airflow\\/gcs\\/dags\\/// > airflow_variables_ci.json
sydneynotthecity marked this conversation as resolved.
Show resolved Hide resolved
python -m pip install --upgrade pip
pip install -r requirements-ci.txt

Expand Down Expand Up @@ -65,3 +65,16 @@ jobs:
env:
GOOGLE_CLOUD_PROJECT: hubble-261722
BUCKET: us-central1-hubble-2-d948d67b-bucket

- name: Update Airflow variables
uses: actions-hub/gcloud@master
env:
PROJECT_ID: hubble-261722
APPLICATION_CREDENTIALS: "${{ secrets.CREDS_TEST_HUBBLE }}"
COMPOSER_ENVIRONMENT: hubble-2
LOCATION: us-central1
with:
args: >
components install kubectl && gcloud composer environments run
$COMPOSER_ENVIRONMENT --location $LOCATION variables import
-- gcsfuse/variables.json
File renamed without changes.
10 changes: 8 additions & 2 deletions dags/stellar_etl_airflow/add_files_to_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def _create_files_list(env: str) -> Tuple[str, List[str]]:
# copy airflow configuration file
copy(f"airflow-{env}.cfg", f"{temp_dir}/airflow.cfg")
copy(f"airflow-{env}.cfg", f"airflow.cfg")

# copy airflow variables json
copy(f"airflow_variables_{env}.json", f"{temp_dir}/variables.json")
copy(f"airflow_variables_{env}.json", f"variables.json")
sydneynotthecity marked this conversation as resolved.
Show resolved Hide resolved
dags = glob(f"{temp_dir}/**/*.*", recursive=True)
return (temp_dir, dags)

Expand All @@ -53,7 +55,11 @@ def upload_dags_to_composer(bucket_name: str, env: str) -> None:

for f in files:
# remove path to temp dir
if f.endswith(".json"):
if f.endswith(f"variables.json"):
# insert airflow variable file
f = f.replace(f"{temp_dir}/", "")
blob = bucket.blob(f)
elif f.endswith(".json"):
# create schemas directory
f = f.replace(f"{temp_dir}/", "schemas/")
schema_destination = "dags/" + f
Expand Down