Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/plmercereau/drone-pr-merge
GitHub PR merge "event" for Drone CI
https://github.com/plmercereau/drone-pr-merge
ci-cd drone-ci github github-api pull-request shell
Last synced: 2 months ago
JSON representation
GitHub PR merge "event" for Drone CI
- Host: GitHub
- URL: https://github.com/plmercereau/drone-pr-merge
- Owner: plmercereau
- Created: 2019-09-30T17:13:11.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-10-01T11:10:08.000Z (about 5 years ago)
- Last Synced: 2024-10-23T09:39:07.261Z (2 months ago)
- Topics: ci-cd, drone-ci, github, github-api, pull-request, shell
- Language: Shell
- Homepage:
- Size: 15.6 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Handling Pull Request mergers with Drone CD and the GitHub API
This is a very small example of a workaround to allow Drone.io to handle PR merge events.
This repo is rather a proof of concept, but contributions are welcome to make it more effective, while waiting for the Drone team to implement some kind of a 'pull_request_merge' event.### Rationale
Pipelines that deploy a temporary version of an application for each pull request are quite common.
But such on-the-fly environments then need to be destroyed once the pull request is merged.
This script coudl allow to reach the branch of origin once the PR is merged, to destroy the environment that would have been created with the PR.### Requirements
The script requires `jq` and `curl` (not installed in Alpine by default).
### How it works
The `get_merged_branch.sh` script reaches the GitHub API to get the right information from the GitHub API, and prints the orginial branch of the PR.
This script can be then called in a Drone pipeline (or any similar CI/CD platform). In the `.drone.yml` of this repo, the output is stored in an environment variable: `export MERGED_FROM_BRANCH=$(./get_merged_branch.sh)`. If the output is empty, then the ongoing step stops with `'[[ -z $MERGED_FROM_BRANCH ]] && exit'`.