-
Notifications
You must be signed in to change notification settings - Fork 0
🚧 D3B-2193 set up GHA to export repo to airflow #7
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
Merged
chris-s-friedman
merged 2 commits into
main
from
infra/cf/dbt-airflow-connection-d3b-2193
Jan 5, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,23 @@ | ||
| name: Export Repo to Airflow | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| send-to-airflow-s3-bucket: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: send repository dispatch | ||
| run: | | ||
| curl -L \ | ||
| -X POST \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| -H "Authorization: Bearer ${{ secrets.INCLUDE_AF_PAT }}" \ | ||
| -H "X-GitHub-Api-Version: 2022-11-28" \ | ||
| https://api.github.com/repos/include-dcc/include-dbt-airflow-mirror/dispatches \ | ||
| -d '{"event_type":"export-to-airflow","client_payload":{"repo": "include-dbt-sandbox", "ref": "'${{ github.ref }}'", "run_id": "'${{ github.run_id }}'"}}' |
This file contains hidden or 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,93 @@ | ||
| """ | ||
| This DAG is a tutorial example DAG that demonstrates the basic structure | ||
| of an Airflow DAG and how to use the BashOperator. It's taken from the | ||
| Airflow documentation here https://airflow.apache.org/docs/apache-airflow/stable/tutorial/fundamentals.html. | ||
|
|
||
| This dag prints the current date, then sleeps for 5 seconds, and finally | ||
| runs a templated bash command that prints the execution date 5 times. | ||
| """ | ||
|
|
||
| import textwrap | ||
| from datetime import datetime, timedelta | ||
|
|
||
| # The DAG object; we'll need this to instantiate a DAG | ||
| from airflow.models.dag import DAG | ||
|
|
||
| # Operators; we need this to operate! | ||
| from airflow.operators.bash import BashOperator | ||
|
|
||
| with DAG( | ||
| "tutorial", | ||
| # These args will get passed on to each operator | ||
| # You can override them on a per-task basis during operator initialization | ||
| default_args={ | ||
| "depends_on_past": False, | ||
| "email": ["[email protected]"], | ||
| "email_on_failure": False, | ||
| "email_on_retry": False, | ||
| "retries": 1, | ||
| "retry_delay": timedelta(minutes=5), | ||
| # 'queue': 'bash_queue', | ||
| # 'pool': 'backfill', | ||
| # 'priority_weight': 10, | ||
| # 'end_date': datetime(2016, 1, 1), | ||
| # 'wait_for_downstream': False, | ||
| # 'sla': timedelta(hours=2), | ||
| # 'execution_timeout': timedelta(seconds=300), | ||
| # 'on_failure_callback': some_function, # or list of functions | ||
| # 'on_success_callback': some_other_function, # or list of functions | ||
| # 'on_retry_callback': another_function, # or list of functions | ||
| # 'sla_miss_callback': yet_another_function, # or list of functions | ||
| # 'on_skipped_callback': another_function, #or list of functions | ||
| # 'trigger_rule': 'all_success' | ||
| }, | ||
| description="A simple tutorial DAG", | ||
| schedule=timedelta(days=1), | ||
| start_date=datetime(2021, 1, 1), | ||
| catchup=False, | ||
| tags=["example"], | ||
| ) as dag: | ||
|
|
||
| # t1, t2 and t3 are examples of tasks created by instantiating operators | ||
| t1 = BashOperator( | ||
| task_id="print_date", | ||
| bash_command="date", | ||
| ) | ||
|
|
||
| t2 = BashOperator( | ||
| task_id="sleep", | ||
| depends_on_past=False, | ||
| bash_command="sleep 5", | ||
| retries=3, | ||
| ) | ||
| t1.doc_md = textwrap.dedent( | ||
| """\ | ||
| #### Task Documentation | ||
| You can document your task using the attributes `doc_md` (markdown), | ||
| `doc` (plain text), `doc_rst`, `doc_json`, `doc_yaml` which gets | ||
| rendered in the UI's Task Instance Details page. | ||
|  | ||
| **Image Credit:** Randall Munroe, [XKCD](https://xkcd.com/license.html) | ||
| """ | ||
| ) | ||
|
|
||
| dag.doc_md = __doc__ # providing that you have a docstring at the beginning of the DAG; OR | ||
| dag.doc_md = """ | ||
| This is a documentation placed anywhere | ||
| """ # otherwise, type it like this | ||
| templated_command = textwrap.dedent( | ||
| """ | ||
| {% for i in range(5) %} | ||
| echo "{{ ds }}" | ||
| echo "{{ macros.ds_add(ds, 7)}}" | ||
| {% endfor %} | ||
| """ | ||
| ) | ||
|
|
||
| t3 = BashOperator( | ||
| task_id="templated", | ||
| depends_on_past=False, | ||
| bash_command=templated_command, | ||
| ) | ||
|
|
||
| t1 >> [t2, t3] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe comment what this does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a docstring at the top of the script indicating what it does. Good idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this syntax of BashOperators do?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry - are you asking about
t1 >> [t2, t3]? That just says thatt2andt3are both dependent ont1running.otherwise, that bashoperator:
instructs airflow to run the commands in
templated_command, in this case{% for i in range(5) %} echo "{{ ds }}" echo "{{ macros.ds_add(ds, 7)}}" {% endfor %}