Skip to content

Commit 354d189

Browse files
committed
Merge remote-tracking branch 'template/dev' into dev
2 parents 59aa2d9 + 950ecf3 commit 354d189

File tree

12 files changed

+427
-189
lines changed

12 files changed

+427
-189
lines changed

.github/workflows/docker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: docker/[email protected]
2222

2323
- name: Log into registry ${{ env.REGISTRY }}
24-
uses: docker/login-action@v3.3.0
24+
uses: docker/login-action@v3.4.0
2525
with:
2626
registry: ${{ env.REGISTRY }}
2727
username: ${{ github.actor }}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: PR Autofix
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '**' # This will run on all branches, and we'll detect the default branch
7+
types: [opened, synchronize]
8+
9+
jobs:
10+
autofix:
11+
name: Autofix Pull Request
12+
runs-on: ubuntu-latest
13+
14+
# Skip if the last 3 commits are from the GitHub Actions bot
15+
if: >
16+
!startsWith(github.event.commits[0].author.name, 'github-actions') ||
17+
!startsWith(github.event.commits[1].author.name, 'github-actions') ||
18+
!startsWith(github.event.commits[2].author.name, 'github-actions')
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0 # We need the full history for comparing branches
25+
ref: ${{ github.head_ref }} # Check out the PR branch
26+
27+
- name: Check if PR targets default branch
28+
id: check-target
29+
run: |
30+
DEFAULT_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
31+
TARGET_BRANCH="${{ github.base_ref }}"
32+
if [ "$TARGET_BRANCH" = "$DEFAULT_BRANCH" ]; then
33+
echo "PR targets the default branch ($DEFAULT_BRANCH). Proceeding with autofix."
34+
echo "should_run=true" >> $GITHUB_OUTPUT
35+
else
36+
echo "PR does not target the default branch ($DEFAULT_BRANCH). Skipping autofix."
37+
echo "should_run=false" >> $GITHUB_OUTPUT
38+
fi
39+
40+
- name: Setup PDM
41+
uses: pdm-project/setup-pdm@v4
42+
if: steps.check-target.outputs.should_run == 'true'
43+
with:
44+
cache: true
45+
46+
- name: Setup Copywrite
47+
if: steps.check-target.outputs.should_run == 'true'
48+
uses: hashicorp/setup-copywrite@5e3e8a26d7b9f8a508848ad0a069dfd2f7aa5339
49+
50+
- name: Install dependencies
51+
if: steps.check-target.outputs.should_run == 'true'
52+
run: pdm install -d
53+
54+
- name: Run linting
55+
if: steps.check-target.outputs.should_run == 'true'
56+
run: pdm run lint
57+
58+
- name: Run formatting
59+
if: steps.check-target.outputs.should_run == 'true'
60+
run: pdm run format
61+
62+
- name: Export requirements
63+
if: steps.check-target.outputs.should_run == 'true'
64+
run: pdm run export
65+
66+
- name: Add license headers
67+
if: steps.check-target.outputs.should_run == 'true'
68+
run: copywrite headers --config .copywrite.hcl
69+
70+
- name: Check for changes
71+
if: steps.check-target.outputs.should_run == 'true'
72+
id: check-changes
73+
run: |
74+
if [[ -n "$(git status --porcelain)" ]]; then
75+
echo "Has changes that need to be committed"
76+
echo "has_changes=true" >> $GITHUB_OUTPUT
77+
else
78+
echo "No changes detected"
79+
echo "has_changes=false" >> $GITHUB_OUTPUT
80+
fi
81+
82+
- name: Commit changes
83+
if: steps.check-target.outputs.should_run == 'true' && steps.check-changes.outputs.has_changes == 'true'
84+
run: |
85+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
86+
git config --local user.name "github-actions[bot]"
87+
git add -A
88+
git commit -m "Autofix: Lint and format code"
89+
90+
- name: Push changes
91+
if: steps.check-target.outputs.should_run == 'true' && steps.check-changes.outputs.has_changes == 'true'
92+
uses: ad-m/github-push-action@77c5b412c50b723d2a4fbc6d71fb5723bcd439aa
93+
with:
94+
# use PAT if available, otherwise use GITHUB_TOKEN
95+
github_token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
96+
branch: ${{ github.head_ref }}

.github/workflows/quality.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Quality Checks
22

3-
on: workflow_call
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
46

57
jobs:
68
quality:

.pre-commit-config.yaml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,14 @@ repos:
2121
exclude: \.(po|pot|yml|yaml)$
2222
- repo: https://github.com/astral-sh/ruff-pre-commit
2323
# Ruff version.
24-
rev: v0.9.10
24+
rev: v0.11.0
2525
hooks:
2626
# Run the linter.
2727
- id: ruff
2828
args: [ --fix ]
2929
# Run the formatter.
3030
- id: ruff-format
31-
- repo: local
32-
hooks:
33-
- id: copywrite
34-
name: copywrite
35-
entry: copywrite headers
36-
language: system
37-
pass_filenames: false
38-
files: .
31+
- repo: https://github.com/bhundven/copywrite # waiting for https://github.com/hashicorp/copywrite/pull/120 to be merged
32+
rev: 937f17f09c46992447dfa8977bb96eda512588c4
33+
hooks:
34+
- id: add-headers

0 commit comments

Comments
 (0)