Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflows: ensure auto-pr always runs on the right commit #132

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
permissions:
# NOTE: Needed to push to the repository.
contents: write
outputs:
auto-pr-ref: ${{ steps.commit.outputs.auto-pr-ref }}
steps:
- name: Check out this repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
Expand Down Expand Up @@ -46,15 +48,22 @@ jobs:
- run: python3 pip-audit-bulk

- name: Commit and push if it changed
id: commit
run: |-
git config user.name "github.actions"
git config user.email "[email protected]"
git add -A
timestamp=$(date -u)
git commit -m "Latest data: ${timestamp}" || exit 0
echo "auto-pr-ref=$(git rev-parse HEAD)" >> "${GITHUB_OUTPUT}"
git push

auto-pr:
needs: [audit]
uses: ./.github/workflows/auto-pr.yml
secrets: inherit
with:
# NOTE: Without this, the reusable workflow will checkout
# the GITHUB_REF from the caller workflow, i.e. the commit
# right before our push above.
ref: ${{ needs.audit.outputs.auto-pr-ref }}
9 changes: 9 additions & 0 deletions .github/workflows/auto-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
required: true
default: true
type: boolean
ref:
required: false
default: ''
woodruffw marked this conversation as resolved.
Show resolved Hide resolved
type: string
workflow_call:
inputs:
pr-limit:
Expand All @@ -19,6 +23,9 @@ on:
dry-run:
default: false # don't dry-run by default when called from another workflow
type: boolean
ref:
default: ${{ github.ref }}
type: string

jobs:
auto-pr:
Expand All @@ -39,6 +46,8 @@ jobs:
with:
fetch-depth: 0
persist-credentials: false
# will expand to '' when unset in workflow_dispatch, i.e. default branch
ref: ${{ inputs.ref }}

- name: Set up Homebrew
id: set-up-homebrew
Expand Down