Skip to content

Commit

Permalink
removing reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kirtimanmishrazipstack committed Jul 18, 2024
1 parent 13a5bdd commit c07ef66
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 240 deletions.
97 changes: 0 additions & 97 deletions .github/workflows/main.yaml

This file was deleted.

131 changes: 93 additions & 38 deletions .github/workflows/pdm-lock-automation.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,97 @@
name: Automate pdm.lock

on:
push:

on: push

jobs:
backend_changes:
uses: ./.github/workflows/reusable-file-change-check.yaml
with:
file_path: backend/pyproject.toml

prompt_changes:
uses: ./.github/workflows/reusable-file-change-check.yaml
with:
file_path: prompt-service/pyproject.toml

root_changes:
uses: ./.github/workflows/reusable-file-change-check.yaml
with:
file_path: pyproject.toml

update-backend-pdm-lock:
needs: backend_changes
if: ${{ needs.backend_changes.outputs.changed == 'true' }}
uses: ./.github/workflows/reusable-update-pdm-lock.yaml
with:
service: 'backend'

update-prompt-service-pdm-lock:
needs: prompt_changes
if: ${{ needs.prompt_changes.outputs.changed == 'true' }}
uses: ./.github/workflows/reusable-update-pdm-lock.yaml
with:
service: 'prompt-service'

update-root-pdm-lock:
needs: root_changes
if: ${{ needs.root_changes.outputs.changed == 'true' }}
uses: ./.github/workflows/reusable-update-pdm-lock.yaml
with:
service:
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 }}"
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
32 changes: 0 additions & 32 deletions .github/workflows/reusable-file-change-check.yaml

This file was deleted.

73 changes: 0 additions & 73 deletions .github/workflows/reusable-update-pdm-lock.yaml

This file was deleted.

0 comments on commit c07ef66

Please sign in to comment.