generated from datumforge/template-buildkite-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init plugin * pipeline
- Loading branch information
Showing
8 changed files
with
324 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,69 @@ | ||
[![Build status](https://badge.buildkite.com/df549c652f77fa3660f4d7f975fd3bb5744e12fb4066719553.svg?branch=main)](https://buildkite.com/datum/template-buildkite-plugin) | ||
[![Build status](https://badge.buildkite.com/7eca2ecc8cd4f571e1c2e26000c51030c808e7bca6b9b25e42.svg)](https://buildkite.com/datum/git-commit-buildkite-plugin) | ||
|
||
# Template Buildkite Plugin | ||
# git-commit | ||
|
||
Check the [buildkite organization](https://github.com/buildkite-plugins) or [website](https://buildkite.com/plugins) to see if your plugin already exists or we can contribute to it ! | ||
|
||
Be sure to update this readme with your plugin information after using the template repository - for more info checkout Buildkite's documentation [here](https://buildkite.com/docs/plugins) | ||
A buildkite plugin to commit and push results of command(s) to a remote git repository | ||
|
||
## Example | ||
|
||
Provide an example of using this plugin, like so: | ||
|
||
Add the following to your `pipeline.yml`: | ||
|
||
```yml | ||
steps: | ||
- command: ls | ||
- command: task generate | ||
plugins: | ||
- a-github-user/template#v1.0.0: | ||
pattern: '*.md' | ||
- datumforge/git-commit#v1.0.0: ~ | ||
``` | ||
|
||
## Developing | ||
The default options commit all changed/added files to `$BUILDKITE_BRANCH` and pushes to `origin`. | ||
|
||
Provide examples on how to modify and test, e.g.: | ||
An example with fully customized options: | ||
|
||
To run the linter: | ||
```shell | ||
task lint | ||
```yml | ||
steps: | ||
- command: task generate | ||
plugins: | ||
- datumforge/git-commit#v1.0.0: | ||
add: app/ | ||
branch: mitb | ||
create-branch: true | ||
message: "Task generate output" | ||
remote: upstream | ||
user: | ||
name: bender-rodriguez | ||
email: brodriguez@datum.net | ||
``` | ||
|
||
To run the tests: | ||
## Configuration | ||
|
||
### add (optional, defaults to `.`) | ||
|
||
A pathspec that will be passed to `git add -A` to add changed files. | ||
|
||
### branch (optional, defaults to `$BUILDKITE_BRANCH`) | ||
|
||
The branch where changes will be committed. Since Buildkite runs builds in a detached HEAD state, this plugin will fetch and checkout the given branch prior to committing. Unless we're creating a new branch. See `create-branch` | ||
|
||
### create-branch (optional, defaults to `false`) | ||
|
||
When set to true the branch will be created, rather than fetched from the remote | ||
|
||
### message (optional, defaults to `Build #${BUILDKITE_BUILD_NUMBER}`) | ||
|
||
The commit message | ||
|
||
### remote (optional, defaults to `origin`) | ||
|
||
The git remote where changes will be pushed | ||
|
||
### user.email (optional) | ||
|
||
If given, will configure the git user email for the repo | ||
|
||
### user.name (optional) | ||
|
||
If given, will configure the git user name for the repo | ||
|
||
## Developing | ||
|
||
```shell | ||
task test | ||
``` | ||
Requires [taskfile](https://taskfile.dev/installation/) - `task lint` and `task test` to validate updates to the plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,42 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
if [[ ${BUILDKITE_COMMAND_EXIT_STATUS:-0} != "0" ]] | ||
then | ||
echo "--- Skipping git-commit because the command failed" | ||
exit 0 | ||
fi | ||
|
||
remote=${BUILDKITE_PLUGIN_GIT_COMMIT_REMOTE:-origin} | ||
branch=${BUILDKITE_PLUGIN_GIT_COMMIT_BRANCH:-${BUILDKITE_BRANCH}} | ||
message=${BUILDKITE_PLUGIN_GIT_COMMIT_MESSAGE:-"Build #${BUILDKITE_BUILD_NUMBER}"} | ||
|
||
if [[ -n ${BUILDKITE_PLUGIN_GIT_COMMIT_USER_NAME+x} ]] | ||
then | ||
git config user.name "$BUILDKITE_PLUGIN_GIT_COMMIT_USER_NAME" | ||
fi | ||
|
||
if [[ -n ${BUILDKITE_PLUGIN_GIT_COMMIT_USER_EMAIL+x} ]] | ||
then | ||
git config user.email "$BUILDKITE_PLUGIN_GIT_COMMIT_USER_EMAIL" | ||
fi | ||
|
||
if [[ ${BUILDKITE_PLUGIN_GIT_COMMIT_CREATE_BRANCH:-false} = "true" ]] | ||
then | ||
git checkout -b "$branch" | ||
else | ||
git fetch "$remote" "$branch:$branch" | ||
git checkout "$branch" | ||
fi | ||
git add -A "${BUILDKITE_PLUGIN_GIT_COMMIT_ADD:-.}" | ||
|
||
if ! git diff-index --quiet HEAD | ||
then | ||
echo "--- Committing changes" | ||
git commit -m "${message}" | ||
echo "--- Pushing to origin" | ||
git push "$remote" "$branch" | ||
else | ||
echo "--- No changes to commit" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
--- | ||
name: template-buildkite-plugin | ||
description: what your plugin does | ||
author: Datum | ||
requirements: | ||
- if you have requirements | ||
name: Git Commit | ||
description: A buildkite plugin to commit and push changes to a git repository | ||
author: https://github.com/datumforge | ||
requirements: [] | ||
configuration: | ||
properties: | ||
propertyname: | ||
add: | ||
type: string | ||
required: [] | ||
# - if any properties are required | ||
dependencies: | ||
dependencyname: [dep] | ||
branch: | ||
type: string | ||
create-branch: | ||
type: boolean | ||
message: | ||
type: string | ||
remote: | ||
type: string | ||
user: | ||
type: object | ||
properties: | ||
email: | ||
type: string | ||
name: | ||
type: string |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.