Coder Social home page Coder Social logo

ministryofjustice / analytics-platform-concourse-github-org-resource Goto Github PK

View Code? Open in Web Editor NEW
1.0 11.0 1.0 108 KB

Concourse resource for Github organizations

License: MIT License

Python 97.37% Dockerfile 2.63%
analytics-platform concourse concourse-resource github concourse-pipeline data-engineering

analytics-platform-concourse-github-org-resource's Introduction

Docker Repository on Quay

Github Organization Resource

Provides a Concourse resource for Github Organizations. Used to create pipelines for org repos when deploying a webapp on the Analytical Platform

Resource configuration

These parameters go into the source fields of the resource type. Bold items are required:

Parameter Description
access_token Github access token
name Name of the Github organization
concourse_url Base URL of the Concourse API, eg: https://concourse.example.com
username Concourse basic auth username
password Concourse basic auth password
team_name Concourse team name
cookie-secret Secret used to encrypt deployed webapp session cookies
cluster-ca Base64 encoded PEM
token Bearer token for Kubernetes
skip_ssl_verification Whether curl should verify SSL certificates. (Default false)

Behaviour

check: Fetch Organization versions

A version corresponds to the timestamp of the last push to any of the org's repositories.

in: Fetch Organization

Retrieves the Organization JSON object into the org file and a list of repositories in the repos file.

out: Create pipelines for any Org repos that want one

Creates pipelines for any repo for which their does not already exist a pipeline with the same name, and which contains a Jenkinsfile (for now).

Installation

This resource is not included with Concourse CI. You must integrate this resource in the resource_types section of your pipeline.

resource_types:
- name: github-org
  type: docker-image
  source:
    repository: quay.io.mojanalytics/github-org-resource
    tag: v0.1.3

resources:
- name: moj-analytical-services
  type: github-org
  source:
    name: moj-analytical-services
    access_token: ((github-access-token))
    concourse_url: ((concourse-url))
    username: ((concourse-username))
    password: ((concourse-password))
    team_name: ((concourse-team-name))
    cookie-secret: ((cookie-secret))
    cluster-ca: ((cluster-ca))
    token: ((token))

jobs:
- name: deploy
  plan:
  - get: moj-analytical-services
    trigger: true

Release process

Changing this resource is not enough to release it. A new release tag needs to be created and Concourse needs to be instructed to use it.

Here are the steps:

  1. Create a GitHub release
  2. Update the config (concourse-org-pipeline.yaml) to use this new version (example PR here)
  3. Upgrade the helm release for the concourse-org-pipeline helm chart (see "Installing the Chart" section of README)

Once this above is done, newly created pipelines will use the new version of the pipeline templates.

NOTE: Existing pipelines are not affected. Generally manually delete a concourse pipeline (using fly destroy-pipeline) is safe as Concourse will automatically re-create a pipeline, and use the latest stable version of it.

If the pipeline change is just in one of the custom resource types' version (e.g. ecr-repo, pull-request, auth0-client, helm, kubernetes, etc...) there is now a way to set the version of a resource on all existing pipelines:

Here an example of how to invoke this script:

$ ./update-pipelines-resource-types.py --help
Usage: update-pipelines-resource-types.py [OPTIONS]

Options:
  -b, --fly-binary-path TEXT      path to the fly binary (the Concourse cli)
  -c, --concourse-url TEXT        URL of Concourse
  -t, --fly-target TEXT           Concourse's fly target name
  -n, --concourse-team-name TEXT  Concourse team where the pipelines to update
                                  are

  -r, --resource-name TEXT        Name of the custom resource to update. Note
                                  this is the name used in the pipelines (e.g.
                                  'auth0-client')  [required]

  -v, --resource-tag TEXT         New version/tag of the resource  [required]
  -d, --dry-run                   When true, will not update the upstream
                                  Concourse pipeline

  -i, --interactive               Run fly set-pipeline interactively
  --help                          Show this message and exit.

Let's say for example that you want to update all the pipelines to use concourse-auth0-resource v2.0.2.

First you need to find out what this resource is called in the pipeline, in this case if you check the webapp pipeline definition, in the resource_types section you'll see that this resource is instantiated with the name auth0-client, this will be the value you'll pass for the resource-name argument of the script.

This is the command you'd invoke (remove --dry-run when you want the script to update the upstream Concourse pipelines):

$ ./update-pipelines-resource-types.py --resource-name=auth0-client --resource-tag=v2.0.2 --dry-run
Fly binary path [/usr/local/bin/fly]:
Concourse url [https://concourse.services.dev.mojanalytics.xyz]:
Fly target [dev-main]:
Concourse team name [main]:
logging in to team 'main'

1: ap-main
2: Basic Auth
choose an auth method: 1

navigate to the following URL in your browser:

    https://concourse.services.dev.mojanalytics.xyz/auth/oauth?team_name=main&fly_local_port=59103

or enter token manually: target saved
  [####--------------------------------]   12%  00:01:27

NOTE: script requires Concourse's command line tool fly. Also be sure you install its dependency by running pip install -r requirements.dev.txt to be sure its Python dependencies are satisfied.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b feature/new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin feature/new-feature
  5. Submit a pull request.

License

MIT Licence (MIT)

analytics-platform-concourse-github-org-resource's People

Contributors

andyhd avatar andylightfoot avatar calumabarnett avatar davidread avatar djsd123 avatar isichei avatar mralecjohnson avatar r4vi avatar s-block avatar xoen avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

uk-gov-mirror

analytics-platform-concourse-github-org-resource's Issues

A branch protection setting is not enabled: codeowners require reviews

Hi there
The default branch protection setting called codeowners require review is not enabled for this repository
This option affects a pull request, i.e a PR will need to be reviewed and approved by a CODEOWNER before it can be merged.
See repository settings/Branches/Branch protection rules
Either add a new Branch protection rule or edit the existing branch protection rule and select the Require review from Code Owners option
Create a .github/CODEOWNERS file
Add a or multiple entries of @ministryofjustice/team_name to the CODEOWNERS file
The team_name shall be a team from within the MoJ teams: https://github.com/orgs/ministryofjustice/teams
See GH Codeowners documentation: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
See the repository standards: https://github.com/ministryofjustice/github-repository-standards
See the report: https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/github_repositories
Please contact Operations Engineering on Slack #ask-operations-engineering, if you need any assistance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.