-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b76979
commit 028fd43
Showing
1 changed file
with
95 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: Pyproject.toml change check | ||
|
||
on: push | ||
|
||
jobs: | ||
check_pyproject_changes: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
directory: [backend, prompt-service, root] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Check file changes | ||
id: check | ||
run: | | ||
if [ "${{ matrix.directory }}" = "root" ]; then | ||
file_path="pyproject.toml" | ||
else | ||
file_path="${{ matrix.directory }}/pyproject.toml" | ||
fi | ||
echo "checking changes for $file_path" | ||
echo "changed=false" >> $GITHUB_ENV | ||
if git diff --name-only HEAD^ $file_path | grep -q $file_path; then | ||
echo "changes in $file_path" | ||
echo "changed=true" >> $GITHUB_ENV | ||
fi | ||
- name: Set output | ||
id: set_output | ||
run: echo "::set-output name=changed::${{ env.changed }}" | ||
if: always() | ||
|
||
- name: Set up Python | ||
if: steps.set_output.outputs.changed == 'true' | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: Install PDM | ||
if: steps.set_output.outputs.changed == 'true' | ||
run: python -m pip install pdm | ||
|
||
- name: Update and add pdm.lock | ||
if: steps.set_output.outputs.changed == 'true' | ||
run: | | ||
if [ "${{ matrix.directory }}" != "root" ]; then | ||
cd ${{ matrix.directory }} | ||
fi | ||
echo "current dir before: "; pwd | ||
echo "files in dir before: "; ls -al | ||
if [ ! -d ".venv" ]; then | ||
echo 'Creating virtual environment inside "${{ matrix.directory }}".' | ||
pdm venv create -w virtualenv --with-pip | ||
else | ||
echo "Virtual environment already exists." | ||
fi | ||
source .venv/bin/activate | ||
pdm lock | ||
echo "current dir after: "; pwd | ||
echo "files in dir after: "; ls -al | ||
git add pdm.lock | ||
- name: Running pre-commit and commit pdm.lock | ||
if: steps.set_output.outputs.changed == 'true' | ||
run: | | ||
echo "current root dir: "; pwd | ||
echo "files in root dir: "; ls -al | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
if [ ! -d ".venv" ]; then | ||
echo "Creating virtual environment inside root" | ||
pdm venv create -w virtualenv --with-pip | ||
else | ||
echo "Virtual environment already exists." | ||
fi | ||
source .venv/bin/activate | ||
pip install pre-commit~=3.6.2 | ||
git add .pre-commit-config.yaml | ||
pre-commit run | ||
if [ "${{ matrix.directory }}" != "root" ]; then | ||
git commit -m "Update pdm.lock for ${{ matrix.directory }}" | ||
else | ||
git commit -m "Update pdm.lock for root directory" | ||
fi | ||
# git push |