aboutsummaryrefslogblamecommitdiffstats
path: root/dispatch.sr.ht/github.md
blob: dc2fc3541619667b2d748f5886df40562524a875 (plain) (tree)
1
2
3
4
5
6
7



                         

                                                                               
 






                                                                             
























                                                                              
                                                                           

                                                                                       










                                                                                
                                                                   


                  
                                                          




                                                                                
                                                                    




                                                                               
                                                                               
---
title: GitHub integration
---

dispatch.sr.ht supports various integrations with [GitHub](https://github.com).
Some tips are provided here.

# Configuration

When setting up a new GitHub task on dispatch.sr.ht, your GitHub repositories
will be shown for selection. This list only contains repositories for which
you are the owner. Repositories that are forks of another GitHub repo are
not available for dispatch.sr.ht tasks due to GitHub API limitations.

# Build environment

dispatch.sr.ht will check out the specific commit you pushed when submitting
builds, and will rewrite the upstream clone URL to the fork when building pull
requests.

## Configuring your sources list

Do not include `.git` at the end of your git clone URLs.

## Environment variables

The following environment variables are set when building commits:

- `GITHUB_DELIVERY`: the webhook delivery UUID that triggered this build
- `GITHUB_EVENT`: the event type ("push") that triggered this build
- `GITHUB_REF`: the ref (e.g. "refs/heads/master") that was updated
- `GITHUB_REPO`: the full name (e.g. "username/repo_name") of the GitHub repo

The following environment variables are set when building pull requests:

- `GITHUB_DELIVERY`: the webhook delivery UUID that triggered this build
- `GITHUB_EVENT`: the event type ("push") that triggered this build
- `GITHUB_PR_NUMBER`: the pull request number
- `GITHUB_PR_TITLE`: the title of the pull request
- `GITHUB_PR_BODY`: the body message (aka cover letter) of the pull request
- `GITHUB_BASE_REPO`: the full name (e.g. "username/repo_name") of the base repo
- `GITHUB_HEAD_REPO`: the full name (e.g. "username/repo_name") of the head repo (fork)

# Configuring branch protection rules on GitHub

If you choose the "auto-merge" setting, builds.sr.ht will attempt to merge the
pull request once the build completes successfully. You will likely want to add
branch protection rules on GitHub to prevent this from happening before the pull
request is reviewed.

To edit your branch protection rules, start by visiting "Branches" in your
repository's settings.

![Screenshot of the "branches" page](https://legacy.sr.ht/465d.png)

Select "Add rule".

![Screenshot of "add rule"](https://legacy.sr.ht/rtPV.png)

Specify the branches you want the rule to apply to (e.g. "master") and configure
the criteria which must be met for the pull request to be mergeable. For
example, to require the code to be reviewed before merge:

![Screenshot of code review settings](https://legacy.sr.ht/UeBt.png)

**Important**: if your account is an administrator on this GitHub repository,
attempts to merge will succeed *even if the branch protection rules are unmet*.
You must enable the "Include administrators" option to prevent this.

![Screenshot of "Include administrators" option](https://legacy.sr.ht/7VYq.png)