Skip to content

ci/update: cleanup & fix re-apply logic now that we use nixvim-ci[bot] #3418

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

Merged
merged 2 commits into from
Jun 3, 2025
Merged
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
30 changes: 22 additions & 8 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,29 @@ jobs:
app-id: ${{ vars.CI_APP_ID }}
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}

- name: Get GitHub App User ID
id: user-id
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
- name: Get GitHub App user info
id: user-info
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
slug: ${{ steps.app-token.outputs.app-slug }}
run: |
name="$slug[bot]"
name_regex="$slug"'\[bot\]'
id=$(gh api "/users/$name" --jq .id)
{
echo "id=$id"
echo "name=$name"
echo "email=$id+$name@users.noreply.github.com"
echo 'author-regex=^'"$name_regex"' <'"$id+$name_regex"'@users\.noreply\.github\.com>$'
} >> "$GITHUB_OUTPUT"

- name: Configure git
env:
name: ${{ steps.user-info.outputs.name }}
email: ${{ steps.user-info.outputs.email }}
run: |
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
git config --global user.email '${{ steps.user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
git config --global user.name "$name"
git config --global user.email "$email"

- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -148,13 +161,14 @@ jobs:
- name: Apply commits from the open PR
id: re_apply
if: (inputs.re_apply || github.event_name == 'schedule') && steps.open_pr_info.outputs.number
env:
author_regex: ${{ steps.user-info.outputs.author-regex }}
run: |
# The base is the most recent commit on the remote branch by github-actions[bot]
# The base is the most recent commit on the remote branch authored by nixvim-ci
# This should be a flake.lock bump or a generated-files update
# We will cherry-pick all commits on the remote _after_ the $base commit
remote="origin/$pr_branch"
author_rxp='^github-actions\[bot\] <41898282+github-actions\[bot\]@users\.noreply\.github\.com>$'
base=$(git rev-list --author="$author_rxp" --max-count=1 "$remote")
base=$(git rev-list --author="$author_regex" --max-count=1 "$remote")
commits=( $(git rev-list --reverse "$base..$remote") )
if [[ -n "$commits" ]]; then
echo "Applying ${#commits[@]} commits..."
Expand Down