GitHub

Add a donation button to your pull requests

Add a donation button to your PRs, automatically

Prerequisites

  • On your Account page click the "Unlock" button to access the integration capability.

  • On the Integrations page - generate a token. Keep it safe!

The Perk.Exchange GitHub action https://github.com/perkexchange/github-action generates invoices based on workflow input. The other actions listed in the sample steps below are included to help produce a full solution.

Instructions

  1. In your workflow directory create a pull request template having a placeholder for a button. For example DONATE_BUTTON. The button can go anywhere in the text.

.github/pull_request_template.md
## Description

Please include a summary of the changes and the related issue.

## Please support us

%DONATE_BUTTON%
  1. Create workflow instructions for the pull_request opened event. Add steps for perkexchange/github-action followed by actions/checkout and kaskar2008/action-pr-description-replace.

.github/workflows/create-pr.yml
name: My Workflow
on:
  pull_request:
    types: [ opened ]
jobs:
  create-pr:
    runs-on: ubuntu-latest

    steps:
      - uses: perkexchange/github-action@v0.16-alpha
        name: Perk.Exchange Reward
        with:
            apiToken: ${{ secrets.PERKEXCHANGE_APITOKEN }}
            amount: 1
            currency: "USD"
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.head_ref }}            
      - name: PR description replace
        uses: kaskar2008/action-pr-description-replace@v1.0.0
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          find: '%DONATE_BUTTON%'
          replace: "[![Badge](https://perk.exchange/img/badges/perk.exchange/${{ github.repository_owner }}:${{ github.event.repository.name }}:${{ github.head_ref }}/Donation-Made?cb=1 'Perk Badge')](https://perk.exchange/link/invoice/perk.exchange/${{ github.repository_owner }}:${{ github.event.repository.name }}:${{ github.head_ref }})"

Customize the perkexchange/github-action step with a donation amount or currency. Other values like memo and orderId can be customized.

  1. Add your integration token from Prerequisites to a new Actions secret called PERKEXCHANGE_APITOKEN.

  2. The github action is setup. When a pull request is opened in the repo, an invoice will be created in Perk.Exchange for the amount and currency specified. A button will appear on the pull request page. When a user clicks the button they can view the details of the invoice and pay it using Code Wallet.

Last updated

Was this helpful?