Skip to content
Open
Changes from 1 commit
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
78 changes: 78 additions & 0 deletions .github/workflows/git-ai-notes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
name: Git AI notes

# Reusable workflow. Consolidates git-ai AI-authorship notes (refs/notes/ai) at
# PR-merge time, so attribution survives rebase and squash merges: those give the
# merged commit a new SHA, which strands the note on the pre-merge commit.
#
# Callers own the trigger and must grant `contents: write`, because a called
# workflow cannot widen its own permissions:
#
# name: Git AI
# on:
# pull_request:
# types: [closed, synchronize]
# permissions:
# contents: write
# jobs:
# git-ai:
# uses: gooddata/github-actions-public/.github/workflows/git-ai-notes.yaml@<sha>
#
# FORK PULL REQUESTS ARE NOT SUPPORTED, BY DESIGN.
# `pull_request` runs originating from a fork get a read-only GITHUB_TOKEN, so
# the push to refs/notes/ai cannot succeed. Those runs are skipped explicitly
# below rather than left to fail with a confusing permissions error.
# Do NOT "fix" this by moving callers to `pull_request_target`: that runs in
# base-repo context with a write token and is a privilege-escalation vector.
# On a fork PR, attribution stays in-band via the commit's own trailers.
#
# Supply-chain hardening vs. the stock `git-ai ci github install` output:
# * Installs from the GitHub release asset, NOT usegitai.com, which removes the
# vendor host, and its telemetry, from the trust path.
# * Pins an exact git-ai version (GIT_AI_VERSION) instead of "latest".
# * Verifies the installer's SHA-256 (INSTALLER_SHA256) before running it, the
# same way this org SHA-pins third-party actions. The pinned installer in
# turn verifies the downloaded binary against its embedded checksums.
#
# Bump GIT_AI_VERSION and INSTALLER_SHA256 together, here, once, for every
# calling repository. Get the checksum from that release's SHA256SUMS:
# curl -sSL https://github.com/git-ai-project/git-ai/releases/download/<tag>/SHA256SUMS

on:
workflow_call:

env:
GIT_AI_VERSION: v1.6.24
# sha256 of install.sh for GIT_AI_VERSION, from that release's SHA256SUMS
INSTALLER_SHA256: ad175700758a9053d38b7221dede5cdc047131d8d6894c2c3398cc048952c687

jobs:
git-ai:
# Fail closed: require a pull_request payload, exclude forks (read-only
# token), then run on merge or on a push to an open PR.
if: >-
github.event.pull_request != null
&& github.event.pull_request.head.repo.fork != true
&& (github.event.pull_request.merged == true
|| github.event.action == 'synchronize')
Comment thread
chrisbonilla95 marked this conversation as resolved.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Install git-ai (pinned + checksum-verified)
run: |
set -euo pipefail
installer="$(mktemp)"
curl --fail --location --silent --show-error \
-o "$installer" \
"https://github.com/git-ai-project/git-ai/releases/download/${GIT_AI_VERSION}/install.sh"
echo "${INSTALLER_SHA256} ${installer}" | sha256sum -c -
bash "$installer"
echo "$HOME/.git-ai/bin" >> "$GITHUB_PATH"
- name: Run git-ai
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git-ai ci github run