Merge branch 'main' of github.com:Zipstack/unstract into feat/UN-1451… #13
Workflow file for this run
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: Automate pdm.lock | |
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 --quiet main -- $file_path; then | |
echo "No changes detected in $file_path against main branch." | |
else | |
echo "Changes detected in $file_path against main branch." | |
echo "changed=true" >> $GITHUB_ENV | |
fi | |
- name: Set output | |
id: set_output | |
run: echo "::set-output name=changed::${{ env.changed }}" | |
- name: Set up Python | |
if: steps.set_output.outputs.changed == 'true' | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Set up Go | |
if: steps.set_output.outputs.changed == 'true' | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.22.5' | |
- name: Install PDM | |
if: steps.set_output.outputs.changed == 'true' | |
run: python -m pip install pdm==2.16.1 | |
- name: Update and add pdm.lock | |
if: steps.set_output.outputs.changed == 'true' | |
run: | | |
if [ "${{ matrix.directory }}" != "root" ]; then | |
cd ${{ matrix.directory }} | |
fi | |
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 -G :all | |
git add pdm.lock | |
- name: Running pre-commit and commit pdm.lock | |
if: steps.set_output.outputs.changed == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo "current root dir: "; pwd | |
echo "files in root dir: "; ls -al | |
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 pdm-lock-check | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git commit -m "Update pdm.lock for ${{ matrix.directory }}" | |
git push origin ${{ github.ref_name }} |