Skip to content

Commit

Permalink
Use hash of updated lock files in branch name
Browse files Browse the repository at this point in the history
This prevents the workflow failing when the previous branch hasn't
been merged. It was finding the branch already existed on the
remote and failing.
  • Loading branch information
jfrost-mo committed Oct 5, 2023
1 parent 622a19b commit dec8836
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/conda-lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git switch -c "conda-lock-$(sha256sum ${{ runner.temp }}/lock_file_hashes | head -c 8)"
git switch -c "conda-lock-files"
tox -e py39-lock,py310-lock,py311-lock
- name: Create pull requests
Expand All @@ -47,9 +47,10 @@ jobs:
echo "Lock files unchanged. Skipping pull request..."
exit 0
fi
# Update lock_file_hashes so pushed branch name is unique.
sha256sum requirements/* > ${{ runner.temp }}/lock_file_hashes
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."
gh pr create --base main --title "[CI] Update conda lock files" --body "Created automatically by GitHub Actions."

0 comments on commit dec8836

Please # to comment.