From a1b6bac956184ea509b47bd350e3c6ae4c604640 Mon Sep 17 00:00:00 2001 From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> Date: Tue, 5 Nov 2024 08:23:41 -0500 Subject: [PATCH 1/6] Create GitHub action to run djlint and commit changes (#2864) --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/OWASP-BLT/BLT?shareId=XXXX-XXXX-XXXX-XXXX). --- .github/workflows/run-djlint.yml | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/run-djlint.yml diff --git a/.github/workflows/run-djlint.yml b/.github/workflows/run-djlint.yml new file mode 100644 index 000000000..ea0515c71 --- /dev/null +++ b/.github/workflows/run-djlint.yml @@ -0,0 +1,35 @@ +name: Run djlint + +on: + workflow_dispatch: + +jobs: + run-djlint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install djlint + run: | + python -m venv venv + . venv/bin/activate + pip install djlint + + - name: Run djlint + run: | + . venv/bin/activate + djlint --reformat . + + - name: Commit changes + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Apply djlint fixes" || echo "No changes to commit" + git push origin ${{ github.head_ref }} From 16c24c3e500c3a5762304b40fe85372417cc716d Mon Sep 17 00:00:00 2001 From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> Date: Tue, 5 Nov 2024 08:30:56 -0500 Subject: [PATCH 2/6] Update djlint action to run only on specific directories (#2865) --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/OWASP-BLT/BLT?shareId=XXXX-XXXX-XXXX-XXXX). --- .github/workflows/run-djlint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-djlint.yml b/.github/workflows/run-djlint.yml index ea0515c71..fb4f11eeb 100644 --- a/.github/workflows/run-djlint.yml +++ b/.github/workflows/run-djlint.yml @@ -25,6 +25,7 @@ jobs: run: | . venv/bin/activate djlint --reformat . + files: ^company/templates/|^website/templates/ - name: Commit changes run: | From 18ef9055d559b05bcc08ba2dee5d0b861a08d147 Mon Sep 17 00:00:00 2001 From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> Date: Tue, 5 Nov 2024 08:34:46 -0500 Subject: [PATCH 3/6] Fix unexpected value 'files' in run-djlint.yml (#2866) --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/OWASP-BLT/BLT?shareId=XXXX-XXXX-XXXX-XXXX). --- .github/workflows/run-djlint.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-djlint.yml b/.github/workflows/run-djlint.yml index fb4f11eeb..4b3c23c23 100644 --- a/.github/workflows/run-djlint.yml +++ b/.github/workflows/run-djlint.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 @@ -24,8 +24,7 @@ jobs: - name: Run djlint run: | . venv/bin/activate - djlint --reformat . - files: ^company/templates/|^website/templates/ + djlint --reformat $(git diff --name-only HEAD^ HEAD | grep -E '^company/templates/|^website/templates/') - name: Commit changes run: | From 94363791a8beae290f0bf650fd8d40bf45057cfe Mon Sep 17 00:00:00 2001 From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> Date: Tue, 5 Nov 2024 08:43:50 -0500 Subject: [PATCH 4/6] Update run-djlint.yml --- .github/workflows/run-djlint.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-djlint.yml b/.github/workflows/run-djlint.yml index 4b3c23c23..3fe15fa70 100644 --- a/.github/workflows/run-djlint.yml +++ b/.github/workflows/run-djlint.yml @@ -6,6 +6,7 @@ on: jobs: run-djlint: runs-on: ubuntu-latest + steps: - name: Checkout code uses: actions/checkout@v4 @@ -18,13 +19,14 @@ jobs: - name: Install djlint run: | python -m venv venv - . venv/bin/activate + source venv/bin/activate pip install djlint - name: Run djlint run: | - . venv/bin/activate - djlint --reformat $(git diff --name-only HEAD^ HEAD | grep -E '^company/templates/|^website/templates/') + source venv/bin/activate + files_to_check=$(find company/templates website/templates -type f -name "*.html") + djlint --reformat $files_to_check - name: Commit changes run: | @@ -32,4 +34,4 @@ jobs: git config --global user.email "github-actions[bot]@users.noreply.github.com" git add . git commit -m "Apply djlint fixes" || echo "No changes to commit" - git push origin ${{ github.head_ref }} + git push origin ${{ github.head_ref }} \ No newline at end of file From 3c53c890f83be7877831c6b8346468f813f0b1de Mon Sep 17 00:00:00 2001 From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> Date: Tue, 5 Nov 2024 08:49:33 -0500 Subject: [PATCH 5/6] Update run-djlint.yml --- .github/workflows/run-djlint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-djlint.yml b/.github/workflows/run-djlint.yml index 3fe15fa70..5512e6a01 100644 --- a/.github/workflows/run-djlint.yml +++ b/.github/workflows/run-djlint.yml @@ -26,7 +26,7 @@ jobs: run: | source venv/bin/activate files_to_check=$(find company/templates website/templates -type f -name "*.html") - djlint --reformat $files_to_check + djlint --reformat $files_to_check || true - name: Commit changes run: | From 578d464c626b14fc4af907262934e3a3de6197e7 Mon Sep 17 00:00:00 2001 From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> Date: Tue, 5 Nov 2024 08:55:55 -0500 Subject: [PATCH 6/6] Update run-djlint.yml --- .github/workflows/run-djlint.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/run-djlint.yml b/.github/workflows/run-djlint.yml index 5512e6a01..7740d3c34 100644 --- a/.github/workflows/run-djlint.yml +++ b/.github/workflows/run-djlint.yml @@ -3,6 +3,9 @@ name: Run djlint on: workflow_dispatch: +permissions: + contents: write + jobs: run-djlint: runs-on: ubuntu-latest