-
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.
resuable workflow to automate pdm lock
- Loading branch information
1 parent
d917bc1
commit 8a3f1f8
Showing
4 changed files
with
165 additions
and
4 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,69 @@ | ||
name: Update PDM Lock Files | ||
|
||
on: | ||
push: | ||
|
||
|
||
jobs: | ||
backend_changes: | ||
uses: ./.github/workflows/reusable-file-change-check.yaml | ||
with: | ||
file_path: backend/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' | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Checkout repository | ||
# uses: actions/checkout@v3 | ||
|
||
# - name: Check backend_changed value | ||
# run: | | ||
# echo "backend_changed value: ${{ needs.backend_changes.outputs.changed }}" | ||
|
||
# - uses: ./.github/workflows/reusable-update-pdm-lock.yaml | ||
# with: | ||
# service: 'backend' | ||
|
||
# update-prompt-service-pdm-lock: | ||
# needs: changes | ||
# if: ${{ needs.changes.outputs.prompt_service_changed == 'true' }} | ||
# - uses: ./.github/workflows/update-pdm-lock.yml | ||
# with: | ||
# service: 'prompt-service' | ||
|
||
# update-platform-service-pdm-lock: | ||
# needs: changes | ||
# if: ${{ needs.changes.outputs.platform_service_changed == 'true' }} | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v3 | ||
# - name: Check platform_service_changed value | ||
# run: | | ||
# echo "platform_service_changed value: ${{ needs.changes.outputs.platform_service_changed }}" | ||
# - uses: ./.github/workflows/update-pdm-lock.yml | ||
# with: | ||
# service: 'platform-service' | ||
|
||
# update-root-pdm-lock: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v3 | ||
# - uses: ./.github/workflows/update-pdm-lock.yml | ||
# with: | ||
# service: '' | ||
|
||
# push-changes: | ||
# needs: [update-backend-pdm-lock, update-prompt-service-pdm-lock, update-platform-service-pdm-lock, update-root-pdm-lock] | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Checkout repository | ||
# uses: actions/checkout@v3 | ||
|
||
# - name: Push changes | ||
# run: git push | ||
# if: success() |
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,33 @@ | ||
# file-change-check.yml | ||
name: File Change Check | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
file_path: | ||
required: true | ||
type: string | ||
outputs: | ||
changed: | ||
description: "Indicates if the file has changed" | ||
value: ${{ jobs.check_file_changes.outputs.changed }} | ||
|
||
jobs: | ||
check_file_changes: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
changed: ${{ steps.check.outputs.changed }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Check file changes | ||
id: check | ||
run: | | ||
echo "checking changes for "${{ inputs.file_path }}""; | ||
echo "changed=false" >> $GITHUB_ENV | ||
if git diff --name-only HEAD^ "${{ inputs.file_path }}" | grep -q "${{ inputs.file_path }}"; then | ||
echo "changes in "${{ inputs.file_path }}""; | ||
echo "changed=true" >> $GITHUB_OUTPUT | ||
fi |
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,59 @@ | ||
name: Update PDM Lock | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
service: | ||
description: 'Service directory to update pdm.lock. Leave empty for root.' | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
update-lock: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: Install PDM | ||
run: python -m pip install pdm | ||
|
||
- name: Update and add pdm.lock | ||
run: | | ||
echo "inside udpate pdm ${{ inputs.service }}"; | ||
if [ -n "${{ inputs.service }}" ]; then | ||
cd ${{ inputs.service }} | ||
fi | ||
pdm venv create -w virtualenv --with-pip | ||
source .venv/bin/activate | ||
pdm lock | ||
# Debugging output | ||
echo "curent dir: "; pwd | ||
echo "Listing files in ${{ inputs.service || 'root' }} directory:"; ls -al | grep pdm.lock | ||
git add pdm.lock | ||
- name: Commit pdm.lock | ||
run: | | ||
echo "Dir: "; pwd | ||
echo "LFiles in ${{ inputs.service || 'root' }} directory:"; ls -al | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
pdm venv create -w virtualenv --with-pip | ||
source .venv/bin/activate | ||
pip install pre-commit~=3.6.2 | ||
git add .pre-commit-config.yaml | ||
pre-commit run | ||
if [ -n "${{ inputs.service }}" ]; then | ||
git commit -m "Update pdm.lock for ${{ inputs.service }}" | ||
else | ||
git commit -m "Update pdm.lock for root directory" | ||
fi |
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