Git Friends can be easily integrated with GitHub Actions to automatically send commit notifications to your IRC channels via MQTT.
-
Add secrets to your repository:
GIT_FRIENDS_SERVER_URL: Your gf-server URL (e.g.,https://git-friends.example.com)GIT_FRIENDS_TOKEN: Authentication token from your server
-
Create a workflow file (
.github/workflows/git-friends.yml):
name: Git Friends Notification
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Get full history for better git info
- name: Send Git Friends notification
uses: your-org/git-friends@main
with:
server-url: ${{ secrets.GIT_FRIENDS_SERVER_URL }}
token: ${{ secrets.GIT_FRIENDS_TOKEN }}- name: Send Git Friends notification
uses: your-org/git-friends@main
with:
server-url: ${{ secrets.GIT_FRIENDS_SERVER_URL }}
token: ${{ secrets.GIT_FRIENDS_TOKEN }}
gf-hook-version: v1.0.0 # Use specific version- name: Send Git Friends notification (dry run)
uses: your-org/git-friends@main
with:
server-url: ${{ secrets.GIT_FRIENDS_SERVER_URL }}
token: ${{ secrets.GIT_FRIENDS_TOKEN }}
dry-run: trueIf you prefer to use the binary directly:
- name: Download and run gf-hook
run: |
# Download the binary
curl -L -o gf-hook https://github.com/your-org/git-friends/releases/latest/download/gf-hook
chmod +x gf-hook
# Run it
./gf-hook --server-url ${{ secrets.GIT_FRIENDS_SERVER_URL }} --github-actions
env:
GIT_FRIENDS_TOKEN: ${{ secrets.GIT_FRIENDS_TOKEN }}The following GitHub Actions environment variables are automatically used:
GITHUB_SHA: Commit hashGITHUB_REPOSITORY: Repository name (e.g.,owner/repo)GITHUB_SERVER_URL: GitHub server URL (usuallyhttps://github.com)GITHUB_REF_NAME: Branch nameGITHUB_ACTOR: User who triggered the actionGITHUB_EVENT_PATH: Path to event payload JSONGITHUB_ACTIONS: Indicates we're in GitHub Actions
- Push events: Commit information from the pushed commit
- Pull request events: Pull request title and information
- Manual dispatch: Uses the current HEAD commit
With usernames, the MQTT topics follow this pattern:
git-friends/{username}/{repository}/{committer}
Example:
git-friends/alice/github_com_owner_repo/john_doe
Messages appear in IRC like this:
[abc1234] owner/repo by John Doe (main): Fix authentication bug - src/auth.rs, tests/auth_test.rs
- No commit information: Ensure
fetch-depth: 0in checkout action - Authentication failed: Check that your token is valid and has the correct username
- Network issues: Verify your server URL is accessible from GitHub Actions
Enable debug logging:
- name: Send Git Friends notification
uses: your-org/git-friends@main
with:
server-url: ${{ secrets.GIT_FRIENDS_SERVER_URL }}
token: ${{ secrets.GIT_FRIENDS_TOKEN }}
env:
RUST_LOG: debugUse dry-run mode to test without sending actual notifications:
- name: Test Git Friends notification
uses: your-org/git-friends@main
with:
server-url: ${{ secrets.GIT_FRIENDS_SERVER_URL }}
token: ${{ secrets.GIT_FRIENDS_TOKEN }}
dry-run: true| Input | Description | Required | Default |
|---|---|---|---|
server-url |
Git Friends server URL | Yes | - |
token |
Authentication token | Yes | - |
gf-hook-version |
Version of gf-hook to use | No | latest |
dry-run |
Run in dry-run mode | No | false |
name: Git Friends Notifications
on:
push:
branches: [ main, develop, feature/* ]
pull_request:
branches: [ main ]
release:
types: [ published ]
jobs:
notify-commits:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Notify commit
uses: your-org/git-friends@main
with:
server-url: ${{ secrets.GIT_FRIENDS_SERVER_URL }}
token: ${{ secrets.GIT_FRIENDS_TOKEN }}
notify-prs:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Notify PR
uses: your-org/git-friends@main
with:
server-url: ${{ secrets.GIT_FRIENDS_SERVER_URL }}
token: ${{ secrets.GIT_FRIENDS_TOKEN }}
notify-releases:
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Notify release
uses: your-org/git-friends@main
with:
server-url: ${{ secrets.GIT_FRIENDS_SERVER_URL }}
token: ${{ secrets.GIT_FRIENDS_TOKEN }}