You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: main/typical_flows/index.html
+90-5Lines changed: 90 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -924,6 +924,57 @@ <h3 id="manage-jobs-as-code-only-for-production">Manage jobs as code only for Pr
924
924
<li>We could also force a specific version with <code>uvx dbt-jobs-as-code@1.2</code></li>
925
925
</ol>
926
926
</details>
927
+
<detailsclass="example">
928
+
<summary>Enhanced GitHub example: Posting plan results as pull request comments</summary>
929
+
<p>This example shows how to capture the plan output and post it as a comment on the pull request, making it easier for reviewers to see what changes will be made.</p>
930
+
<divclass="highlight"><spanclass="filename">plan_on_pr_with_comment.yml</span><pre><span></span><code><spanclass="nt">name</span><spanclass="p">:</span><spanclass="w"></span><spanclass="l l-Scalar l-Scalar-Plain">Plan for syncing dbt Cloud Jobs from YAML</span>
931
+
<spanclass="nt">run-name</span><spanclass="p">:</span><spanclass="w"></span><spanclass="l l-Scalar l-Scalar-Plain">Running dbt-jobs-as-code plan to see what is going to be changed/deleted</span>
<spanclass="w"></span><spanclass="no">printf "Changes from dbt-jobs-as-code (full details are available in the actions logs):\n\`\`\`\n" > plan_output.txt</span>
961
+
<spanclass="w"></span><spanclass="no">dbt-jobs-as-code plan jobs/my_jobs.yml --vars-yml jobs/prod_vars.yml --limit-projects-envs-to-yml >> plan_output.txt</span>
<p>This example uses the <ahref="https://github.com/mshick/add-pr-comment">mshick/add-pr-comment</a> GitHub Action to post the plan output as a comment. The <code>pull-requests: write</code> permission is required for the action to post comments.</p>
976
+
</div>
977
+
</details>
927
978
<p>The relevant GitLab pipelines would be the following:</p>
928
979
<detailsclass="example">
929
980
<summary>Examples of GitLab pipelines for <code>plan</code> and <code>sync</code></summary>
@@ -956,7 +1007,7 @@ <h3 id="manage-jobs-as-code-only-for-production">Manage jobs as code only for Pr
<spanclass="w"></span><spanclass="p p-Indicator">-</span><spanclass="w"></span><spanclass="l l-Scalar l-Scalar-Plain">export DBT_API_KEY=$DBT_API_KEY</span><spanclass="w"></span><spanclass="c1"># Ensure this variable is set in GitLab CI/CD project settings</span>
976
1027
</code></pre></div>
977
1028
</details>
1029
+
<detailsclass="example">
1030
+
<summary>Enhanced GitLab example: Posting plan results as merge request comments</summary>
1031
+
<p>This example shows how to capture the plan output and post it as a comment on the merge request, making it easier for reviewers to see what changes will be made.</p>
<spanclass="w"></span><spanclass="no">printf "Changes from dbt-jobs-as-code (full details are available in the actions logs):\n\`\`\`\n" > plan_output.txt</span>
1051
+
<spanclass="w"></span><spanclass="no">dbt-jobs-as-code plan --limit-projects-envs-to-yml --vars-yml jobs/environments/vars_prod.yml jobs/jobs/**/*.yml >> plan_output.txt 2>&1</span>
<spanclass="w"></span><spanclass="p p-Indicator">-</span><spanclass="w"></span><spanclass="l l-Scalar l-Scalar-Plain">export DBT_API_KEY=$DBT_API_KEY</span><spanclass="w"></span><spanclass="c1"># Ensure this variable is set in GitLab CI/CD project settings</span>
1057
+
</code></pre></div>
1058
+
<divclass="admonition note">
1059
+
<pclass="admonition-title">Note</p>
1060
+
<p>This example requires setting up a <code>CI_AUTOCOMMENTER_API_KEY</code> variable in your GitLab CI/CD settings with a personal access token that has <code>api</code> scope to post comments to merge requests.</p>
1061
+
</div>
1062
+
</details>
978
1063
<hr/>
979
1064
<h3id="manage-jobs-as-code-in-different-environments">Manage jobs as code in different environments</h3>
980
1065
<p>A similar approach to the first case, but in that situation, we use <ahref="../advanced_config/templating/">templated YML files</a> so that the same YML file can be used across different environments, and jobs can be configured based on some variables.</p>
0 commit comments