-
Notifications
You must be signed in to change notification settings - Fork 1
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
628fada
commit ef8d134
Showing
1 changed file
with
66 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,66 @@ | ||
name: Sync Requirements | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'poetry.lock' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
sync_requirements: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.head_ref || github.ref_name }} | ||
|
||
- name: Install Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
|
||
- name: Install Poetry and plugin | ||
run: | | ||
pip install poetry==2.0.1 | ||
poetry self add poetry-plugin-export | ||
- name: Configure Git credentials | ||
run: | | ||
echo "https://${{ secrets.BLOXLINK_LIB_ACCESS }}:@github.com" > $HOME/.git-credentials | ||
git config --global credential.helper store | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "[email protected]" | ||
env: | ||
POETRY_HTTP_BASIC_BLOXLINK_LIB_USERNAME: "{${{ secrets.BLOXLINK_LIB_ACCESS }}}" | ||
|
||
- name: Update requirements.txt | ||
run: poetry export --without-hashes --format=requirements.txt > requirements.txt | ||
|
||
- name: Check for changes | ||
id: changes | ||
run: | | ||
if [[ -n "$(git status --porcelain requirements.txt)" ]]; then | ||
echo "changed=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "changed=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Commit and push if changed | ||
if: steps.changes.outputs.changed == 'true' | ||
run: | | ||
git add requirements.txt | ||
git commit -m "chore: sync requirements.txt with poetry.lock" | ||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||
# Push to the PR branch | ||
git push origin HEAD:${{ github.head_ref }} | ||
else | ||
# Push to main | ||
git push | ||
fi | ||
- name: Cleanup credentials | ||
if: always() | ||
run: rm -f $HOME/.git-credentials |