Run DBT Project #680
This file contains 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
name: Run DBT Project | |
on: | |
schedule: | |
- cron: '0 6 * * *' # 6 AM UTC | |
- cron: '0 14 * * *' # 2 PM UTC | |
- cron: '0 22 * * *' # 10 PM UTC | |
workflow_dispatch: # Allows for manual triggering of the workflow | |
jobs: | |
run-dbt: | |
runs-on: ubuntu-latest | |
env: | |
ACTIONS_PAT: ${{ secrets.ACTIONS_PAT }} | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.12' # Adjust the Python version as needed | |
- name: Cache pip | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
sudo apt-get install git | |
- name: Run DBT | |
run: | | |
cd petro_dbt | |
dbt deps | |
dbt run | |
dbt clean | |
- name: Commit and push changes | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git add . | |
if [ -n "$(git status --porcelain)" ]; then | |
git commit -m "Update files from DBT run" | |
git push https://x-access-token:${{ secrets.ACTIONS_PAT }}@github.com/${{ github.repository }}.git main | |
else | |
echo "No changes to commit" | |
fi |