项目作者: GaneshSPatil

项目描述 :
A Github Action to verify changes done to the GoCD config repository
高级语言: JavaScript
项目地址: git://github.com/GaneshSPatil/gocd-mergeable.git
创建时间: 2020-01-25T06:30:46Z
项目社区:https://github.com/GaneshSPatil/gocd-mergeable

开源协议:Apache License 2.0

下载


🚀 GoCD mergeable - Github Action

Build Status
Coverage Status
Greenkeeper badge
FOSSA Status

A Github Action for verifying changes done to the GoCD config repository.

On every check-in or a pull request, GoCD mergeable action verifies whether modifications done to the GoCD configuration files are valid or not by performing the GoCD preflight check on the specified config repository.

Usage

See action.yml For comprehensive list of options.

Example

Checkout GoCD mergeable YAML Example master branch and pull request for live examples.

Basic

Note: Do not specify GOCD_ADMIN_ACCESS_TOKEN as a plain text value.
Use Github Secrets for specifying the secret access token.

  1. on: [push]
  2. jobs:
  3. verify_config_repository:
  4. runs-on: ubuntu-latest
  5. name: verify config repository changes
  6. steps:
  7. - name: Git checkout
  8. uses: actions/checkout@v2
  9. - name: Verify Config Merge
  10. uses: GaneshSPatil/gocd-mergeable@v1.1.0
  11. with:
  12. GOCD_SERVER_URL: 'https://gocdserverurl.com/go'
  13. GOCD_ADMIN_ACCESS_TOKEN: ${{ secrets.GOCD_ADMIN_ACCESS_TOKEN }}
  14. GOCD_CONFIG_REPOSITORY_ID: 'config-repo-id'

Validate on pull requests

  1. on: [pull_request]
  2. jobs:
  3. verify_config_repository:
  4. runs-on: ubuntu-latest
  5. name: verify config repository changes
  6. steps:
  7. - name: Git checkout
  8. uses: actions/checkout@v2
  9. - name: Verify Config Merge
  10. uses: GaneshSPatil/gocd-mergeable@v1.1.0
  11. with:
  12. GOCD_SERVER_URL: 'https://gocdserverurl.com/go'
  13. GOCD_ADMIN_ACCESS_TOKEN: ${{ secrets.GOCD_ADMIN_ACCESS_TOKEN }}
  14. GOCD_CONFIG_REPOSITORY_ID: 'config-repo-id'

Trigger validation only when configurations changes

GoCD’s pipeline as code allows the pipeline configurations to be defined where the source is (same git repository).
But we often don’t make changes to the pipeline configurations and thus can avoid GoCD mergeable bot check by whitelisting the config files.

  1. on:
  2. push:
  3. paths:
  4. - '.gocd/*.gocd.yml'
  5. - '.gocd/*.gocd.yaml'
  6. jobs:
  7. verify_config_repository:
  8. runs-on: ubuntu-latest
  9. name: verify config repository changes
  10. steps:
  11. - name: Git checkout
  12. uses: actions/checkout@v2
  13. - name: Verify Config Merge
  14. uses: GaneshSPatil/gocd-mergeable@v1.1.0
  15. with:
  16. GOCD_SERVER_URL: 'https://gocdserverurl.com/go'
  17. GOCD_ADMIN_ACCESS_TOKEN: ${{ secrets.GOCD_ADMIN_ACCESS_TOKEN }}
  18. GOCD_CONFIG_REPOSITORY_ID: 'config-repo-id'

Output

  1. Following is an example of successful GoCD mergeable run, when the config repository configurations are valid and can be successfully merged with GoCD.

GoCD mergeable Success Output

  1. Following is an example of failed GoCD mergeable run, when the config repository configurations has some errors (and/or is invalid).

GoCD mergeable Failed Output

A note about security

YAML and JSON plugins do not execute user code because they only parse yaml and json files with pipeline definitions. However, GoCD groovy DSL plugin will evaluate untrusted code on the GoCD server, so beware of the risk that involves:

Enabling GoCD mergeable Github Action for pull requests on a groovy config public repository can allow a malicious Github user to do significant damage by running a script as part of the pull request that steal keys and secrets, remove files and directories, install malware, etc on the GoCD Server.

It is recommended to configure GoCD mergeable Github Action to be executed only on trusted check-ins.

Evaluating the groovy code in a sandbox is currently a work in progress for the groovy plugin.

License

GoCD mergeable is an open source project, under the Apache License, Version 2.0.

FOSSA Status

Contributions

Contributions are welcome! See Contributor’s Guide