Skip to content

Update conda lock files #115

Update conda lock files

Update conda lock files #115

Workflow file for this run

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@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: python3 -m pip install tox tox-conda conda-lock
- name: Update conda
run: conda update -q conda
- name: Hash existing lock files
run: |
shopt -s globstar
sha256sum **/locks/*.txt > ${{ runner.temp }}/lock_file_hashes
cat ${{ runner.temp }}/lock_file_hashes
- name: Switch branch
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git switch -c conda-lock-files
- name: Update CSET lock files
run: tox -e py39-lock,py310-lock,py311-lock,py312-lock
- name: Update workflow lock files
run: |
py_vers="3.9 3.10 3.11 3.12"
for py_ver in $py_vers
do
cp "cset-workflow/requirements/environment.yml" "${{ runner.temp }}/${py_ver}_environment.yml"
echo -e "\n - python = $py_ver" >> "${{ runner.temp }}/${py_ver}_environment.yml"
conda-lock --channel conda-forge --kind explicit --file "${{ runner.temp }}/${py_ver}_environment.yml" --platform linux-64 --filename-template "cset-workflow/requirements/locks/py$(echo $py_ver | sed 's/\.//')-lock-linux-64.txt" &
done
wait
- name: Create pull requests
env:
GH_TOKEN: ${{ github.token }}
run: |
shopt -s globstar
git diff --name-status
if $(sha256sum --status -c ${{ runner.temp }}/lock_file_hashes); then
echo "Lock files unchanged. Skipping pull request..."
exit 0
fi
# Update lock_file_hashes so pushed branch name is unique.
sha256sum **/locks/*.txt > ${{ runner.temp }}/lock_file_hashes
git add **/locks/*.txt
git commit -m "[CI] Update conda lock files"
git push --set-upstream origin "conda-lock-files: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."