All Projects → cloudposse → github-status-updater

cloudposse / github-status-updater

Licence: Apache-2.0 license
Command line utility for updating GitHub commit statuses and enabling required status checks for pull requests

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to github-status-updater

Changelog Ci
Changelog CI is a GitHub Action that generates changelog, Then the changelog is committed and/or commented to the release Pull request.
Stars: ✭ 68 (-18.07%)
Mutual labels:  github-api, ci
prebuild-ci
Use CI to auto upload prebuilds
Stars: ✭ 17 (-79.52%)
Mutual labels:  ci, travis
scalafmt-probot
🤖Github bot for checking code formatting with scalafmt
Stars: ✭ 15 (-81.93%)
Mutual labels:  github-api, status-checks
Env Ci
Get environment variables exposed by CI services
Stars: ✭ 180 (+116.87%)
Mutual labels:  ci, travis
egg-ci
Auto gen ci config file
Stars: ✭ 15 (-81.93%)
Mutual labels:  ci, travis
Wflow
🐆 EXPERIMENTAL -- Runs GitHub Actions workflows locally (local) -- Don't run your YAML like a 🐪
Stars: ✭ 187 (+125.3%)
Mutual labels:  ci, docker-container
kubedock
Kubedock is a minimal implementation of the docker api that will orchestrate containers on a Kubernetes cluster, rather than running containers locally.
Stars: ✭ 79 (-4.82%)
Mutual labels:  ci, cicd
Trytravis
Send local git changes to Travis CI without commits or pushes.
Stars: ✭ 131 (+57.83%)
Mutual labels:  ci, travis
learning-lighthouse-ci
Learning Google's Lighthouse CI from scratch with a minimal template web app (quickstart)
Stars: ✭ 46 (-44.58%)
Mutual labels:  ci, travis
devops-book
运维开发
Stars: ✭ 29 (-65.06%)
Mutual labels:  ci, cicd
Cistern
A terminal UI for Unix to monitor Continuous Integration pipelines from the command line. Current integrations include GitLab, Azure DevOps, Travis CI, AppVeyor and CircleCI.
Stars: ✭ 161 (+93.98%)
Mutual labels:  ci, travis
docker-pega-web-ready
Docker project for generating a tomcat docker image for Pega
Stars: ✭ 46 (-44.58%)
Mutual labels:  ci, cicd
Ci Detector
Detect continuous integration environment and get information of current build
Stars: ✭ 138 (+66.27%)
Mutual labels:  ci, travis
Lighthousebot
Run Lighthouse in CI, as a web service, using Docker. Pass/Fail GH pull requests.
Stars: ✭ 2,251 (+2612.05%)
Mutual labels:  ci, travis
Javascript Testing Best Practices
📗🌐 🚢 Comprehensive and exhaustive JavaScript & Node.js testing best practices (August 2021)
Stars: ✭ 13,976 (+16738.55%)
Mutual labels:  ci, cicd
terraform-aws-s3-bucket
Terraform module that creates an S3 bucket with an optional IAM user for external CI/CD systems
Stars: ✭ 138 (+66.27%)
Mutual labels:  cicd, codefresh
Automatic Release
Automates the release process for GitHub projects.
Stars: ✭ 46 (-44.58%)
Mutual labels:  ci, travis
Lint Diff
💅 Run eslint only in the changed parts of the code
Stars: ✭ 92 (+10.84%)
Mutual labels:  ci, travis
ofcourse
A Concourse resource generator
Stars: ✭ 41 (-50.6%)
Mutual labels:  ci, cicd
plugins
Codefresh plugins repository
Stars: ✭ 16 (-80.72%)
Mutual labels:  ci, codefresh

github-status-updater docker go

Command line utility for updating GitHub commit statuses and enabling required status checks for pull requests.

Useful for CI environments to set more specific commit and build statuses, including setting the target URL (the URL of the page representing the build status, or the URL of the deployed application).

GitHub Status Checks

NOTE: Create a GitHub token with repo:status and public_repo scopes

NOTE: The icons in the image above are the avatars of the users for which the GitHub access tokens are issued

Usage

NOTE: The module accepts parameters as command-line arguments or as ENV variables (or any combination of command-line arguments and ENV vars). Command-line arguments take precedence over ENV vars.

Command-line argument ENV var Description
action GITHUB_ACTION Action to perform: update_state or update_branch_protection
token GITHUB_TOKEN Github access token
owner GITHUB_OWNER Github repository owner
repo GITHUB_REPO Github repository name
ref GITHUB_REF Commit SHA, branch name or tag
state GITHUB_STATE Commit state. Possible values are pending, success, error or failure
context GITHUB_CONTEXT Status label. Could be the name of a CI environment (e.g. my-ci)
description GITHUB_DESCRIPTION Short high level summary of the status
url GITHUB_TARGET_URL URL of the page representing the status

build the Go program locally

go get

CGO_ENABLED=0 go build -v -o "./dist/bin/github-status-updater" *.go

run locally with ENV vars

run_locally_with_env_vars.sh

export GITHUB_ACTION=update_state
export GITHUB_TOKEN=XXXXXXXXXXXXXXXX
export GITHUB_OWNER=cloudposse
export GITHUB_REPO=github-status-updater
export GITHUB_REF=XXXXXXXXXXXXXXXX
export GITHUB_STATE=success
export GITHUB_CONTEXT="my-ci"
export GITHUB_DESCRIPTION="Commit status with target URL"
export GITHUB_TARGET_URL="https://my-ci.com/build/1"

./dist/bin/github-status-updater

After the above command is executed, the commit status will be updated to success with the target URL https://my-ci.com/build/1 (the green check mark in the image below)

GitHub Commit Status

run locally with command-line arguments

run_locally_with_command_line_args.sh

./dist/bin/github-status-updater \
        -action update_state \
        -token XXXXXXXXXXXXXXXX \
        -owner cloudposse \
        -repo github-status-updater \
        -ref XXXXXXXXXXXXXXX \
        -state success \
        -context "my-ci" \
        -description "Commit status with target URL" \
        -url "https://my-ci.com/build/1"

build the Docker image

NOTE: it will download all Go dependencies and then build the program inside the container (see Dockerfile)

docker build --tag github-status-updater  --no-cache=true .

run in a Docker container with ENV vars

run_docker_with_env_vars.sh

docker run -i --rm \
        -e GITHUB_ACTION=update_state \
        -e GITHUB_TOKEN=XXXXXXXXXXXXXXXX \
        -e GITHUB_OWNER=cloudposse \
        -e GITHUB_REPO=github-status-updater \
        -e GITHUB_REF=XXXXXXXXXXXXXXXX \
        -e GITHUB_STATE=success \
        -e GITHUB_CONTEXT="my-ci" \
        -e GITHUB_DESCRIPTION="Commit status with target URL" \
        -e GITHUB_TARGET_URL="https://my-ci.com/build/1" \
        github-status-updater

run in a Docker container with local ENV vars propagated into the container's environment

run_docker_with_local_env_vars.sh

export GITHUB_ACTION=update_state
export GITHUB_TOKEN=XXXXXXXXXXXXXXXX
export GITHUB_OWNER=cloudposse
export GITHUB_REPO=github-status-updater
export GITHUB_REF=XXXXXXXXXXXXXXXX
export GITHUB_STATE=success
export GITHUB_CONTEXT="my-ci"
export GITHUB_DESCRIPTION="Commit status with target URL"
export GITHUB_TARGET_URL="https://my-ci.com/build/1"

docker run -i --rm \
        -e GITHUB_ACTION \
        -e GITHUB_TOKEN \
        -e GITHUB_OWNER \
        -e GITHUB_REPO \
        -e GITHUB_REF \
        -e GITHUB_STATE \
        -e GITHUB_CONTEXT \
        -e GITHUB_DESCRIPTION \
        -e GITHUB_TARGET_URL \
        github-status-updater

run in a Docker container with ENV vars declared in a file

run_docker_with_env_vars_file.sh

docker run -i --rm --env-file ./example.env github-status-updater

GitHub Required Status Checks

The module can be used to update required status checks for Pull Requests.

This is useful for CI environments to set build statuses with URLs to the build pages.

First, repository administrators need to enforce the branch protection and required status checks before a branch is merged in a pull request or before commits on a local branch can be pushed to the protected remote branch.

GitHub Branch Protection Settings

Then, to add my-ci as a status check for branch test of the github-status-updater repo, execute the update_branch_protection action locally

./dist/bin/github-status-updater \
        -action update_branch_protection \
        -token XXXXXXXXXXXXXXXXXXXXXX \
        -owner cloudposse \
        -repo github-status-updater \
        -ref test \
        -context my-ci

or in a Docker container

docker run -i --rm \
        -e GITHUB_ACTION=update_branch_protection \
        -e GITHUB_TOKEN=XXXXXXXXXXXXXXXX \
        -e GITHUB_OWNER=cloudposse \
        -e GITHUB_REPO=github-status-updater \
        -e GITHUB_REF=test \
        -e GITHUB_CONTEXT="my-ci" \
        github-status-updater

After the command executes, status check my-ci will be enabled for the branch as shown in the image below

GitHub Branch Protection Settings

When you create a pull request for the branch, my-ci gets a notification from GitHub, starts the build, and updates the build status to pending by executing the following command to update the status of the last commit (ref XXXXXXXXXXXXXXX)

./dist/bin/github-status-updater \
        -action update_state \
        -token XXXXXXXXXXXXXXXX \
        -owner cloudposse \
        -repo github-status-updater \
        -ref XXXXXXXXXXXXXXX \
        -state pending \
        -context "my-ci" \
        -description "still building..." \
        -url "https://my-ci.com/build/1"

GitHub Status Check Pending

In case of any build errors, my-ci updates the build status to error with the error message in the description parameter

./dist/bin/github-status-updater \
        -action update_state \
        -token XXXXXXXXXXXXXXXX \
        -owner cloudposse \
        -repo github-status-updater \
        -ref XXXXXXXXXXXXXXX \
        -state error \
        -context "my-ci" \
        -description "build error" \
        -url "https://my-ci.com/build/1"

GitHub Status Check Error

When the build succeeds, my-ci updates the build status to success

./dist/bin/github-status-updater \
        -action update_state \
        -token XXXXXXXXXXXXXXXX \
        -owner cloudposse \
        -repo github-status-updater \
        -ref XXXXXXXXXXXXXXX \
        -state success \
        -context "my-ci" \
        -description "build completed" \
        -url "https://my-ci.com/build/1"

GitHub Status Check Success

Integrating with CodeFresh CI/CD Pipelines

github-status-updater can be easily integrated into CI/CD pipelines, especially those that use containers for build steps.

codefresh.yml shows a complete example of a CodeFresh pipeline which performs the following steps:

  • Builds a Docker image for the application
  • Builds a Helm chart
  • Pushes the Docker images (for commits, branches and tags) to CodeFresh repository
  • Executes update_branch_protection action on github-status-updater Docker container to add Staging Environment as a required status check
  • Executes update_state action on github-status-updater Docker container to update Staging Environment deployment status to pending
  • Deploys the Helm chart to a Kubernetes cluster
  • Executes update_state action on github-status-updater Docker container to update Staging Environment deployment status to success

GitHub Status Checks

GitHub Status Checks

References

Help

Got a question?

File a GitHub issue, send us an email or reach out to us on Gitter.

Contributing

Bug Reports & Feature Requests

Please use the issue tracker to report any bugs or file feature requests.

Developing

If you are interested in being a contributor and want to get involved in developing github-status-updater, we would love to hear from you! Shoot us an email.

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Push your work back up to your fork
  5. Submit a Pull request so that we can review your changes

NOTE: Be sure to merge the latest from "upstream" before making a pull request!

License

APACHE 2.0 © 2018 Cloud Posse, LLC

See LICENSE for full details.

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.

About

github-status-updater is maintained and funded by Cloud Posse, LLC.

Cloud Posse

Like it? Please let us know at [email protected]

We love Open Source Software!

See our other projects or hire us to help build your next cloud platform.

Contributors

Erik Osterman
Erik Osterman
Andriy Knysh
Andriy Knysh
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].