Update conda lock files #87
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: "Update conda lock files" | |
on: | |
schedule: | |
- cron: "37 5 * * 1" | |
workflow_dispatch: | |
permissions: | |
pull-requests: write | |
contents: write | |
jobs: | |
update-conda-lock-files: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
- name: Install dependencies | |
run: python3 -m pip install tox tox-conda | |
- name: Update conda | |
run: | | |
conda update -q conda | |
# Install and use libmamba solver as it is much faster. | |
conda install -q -n base conda-libmamba-solver | |
conda config --set solver libmamba | |
- name: Hash existing lock files | |
run: sha256sum requirements/locks/*.txt > ${{ runner.temp }}/lock_file_hashes | |
- name: Update lock files | |
run: | | |
git config --local user.name "$GITHUB_ACTOR" | |
git config --local user.email "[email protected]" | |
git switch -c "conda-lock-$(sha256sum ${{ runner.temp }}/lock_file_hashes | head -c 8)" | |
tox -e py39-lock,py310-lock,py311-lock | |
- name: Create pull requests | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
if $(sha256sum --status -c ${{ runner.temp }}/lock_file_hashes); then | |
echo "Lock files unchanged. Skipping pull request..." | |
exit 0 | |
fi | |
git add requirements/locks/*.txt | |
git commit -m "[CI] Update conda lock files" | |
git push --set-upstream origin "conda-lock-$(sha256sum ${{ runner.temp }}/lock_file_hashes | head -c 8)" | |
# Create PR on GitHub using GitHub CLI. | |
gh pr create --base main --title "[CI] Update conda lock files" \ | |
--body "Created automatically by GitHub Actions." |