Pin dependencies for oxidization. #34
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: Pin dependencies for oxidization. | |
on: | |
workflow_dispatch: | |
schedule: | |
# Run every 1st of Month at 3:25 UTC | |
- cron: "25 3 1 * *" | |
jobs: | |
pin: | |
name: Pinning for ${{ matrix.runs-on }} | |
runs-on: ${{ matrix.runs-on }} | |
strategy: | |
fail-fast: false | |
matrix: | |
runs-on: [ubuntu-latest, windows-latest, macos-latest] | |
env: | |
BRANCH_NAME: auto-dependency-upgrades-${{ matrix.runs-on }} | |
REF_NAME: ${{ github.ref_name }} | |
RUNS_ON: ${{ matrix.runs-on}} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: actions/setup-python@v5 | |
with: | |
# Keep in-sync with ./pyoxidizer.yml | |
python-version: "3.10" | |
- run: python -Im pip install nox | |
- run: nox -e pin_for_pyoxidizer | |
- name: Detect changes | |
id: changes | |
shell: bash | |
run: | |
# This output boolean tells us if the dependencies have actually changed | |
echo "count=$(git status --porcelain=v1 2>/dev/null | wc -l)" >>$GITHUB_OUTPUT | |
- name: Commit & push changes | |
# Only push if changes exist | |
if: steps.changes.outputs.count > 0 | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add . | |
git commit -m "Automated dependency upgrades for $RUNS_ON | |
git push -f origin $REF_NAME:$BRANCH_NAME | |
- name: Open pull request if needed | |
if: steps.changes.outputs.count > 0 | |
shell: bash | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
RUN_ID: ${{ github.run_id }} | |
REPO: ${{ github.repository }} | |
# Only open a PR if the branch is not attached to an existing one | |
run: | | |
PR=$(gh pr list --head $BRANCH_NAME --json number -q '.[0].number') | |
if [ -z $PR ]; then | |
gh pr create \ | |
--head $BRANCH_NAME \ | |
--title "Automated dependency upgrades for $RUNS_ON" \ | |
--body "Full log: https://github.com/$REPO/actions/runs/$RUN_ID" | |
else | |
echo "Pull request already exists, won't create a new one." | |
fi |