Skip to content

Commit

Permalink
feat: Add intial orb sources
Browse files Browse the repository at this point in the history
  • Loading branch information
Timo Reymann authored and Timo Reymann committed Nov 11, 2021
0 parents commit c367c26
Show file tree
Hide file tree
Showing 15 changed files with 508 additions and 0 deletions.
97 changes: 97 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
version: 2.1

.filter_all: &filter_all
filters:
branches:
only: /.*/
tags:
only: /.*/

.filter_tags: &filter_tags
filters:
branches:
ignore: /.*/
tags:
only: /.*/

.require_tests: &require_tests
requires:
- orb-tools/lint
- orb-tools/pack
- shellcheck/check

orbs:
orb-tools: circleci/[email protected]
shellcheck: circleci/[email protected]
aws-s3: circleci/[email protected]
circleci-cli: circleci/[email protected]
semantic-release: trustedshops-public/[email protected]

commands:
upload_for_publish:
parameters:
orb-name:
type: string
description: Name of the orb without the slug
orb-slug:
type: string
description: Slug to publish the orb in, typically this is the org name
orb-version:
type: string
description: Version of the orb
steps:
- attach_workspace:
at: .
- run:
name: Setup AWS region
command: |
echo "export AWS_REGION=eu-central-1" >> $BASH_ENV
- aws-s3/copy:
from: orb.yml
to: s3://${S3_BUCKET_NAME_ORB_RELEASES}/<<parameters.orb-slug>>/<<parameters.orb-name>>/<<parameters.orb-version>>/orb.yml

jobs:
publish-dev:
executor: circleci-cli/default
steps:
- upload_for_publish:
orb-name: trigger-pipeline
orb-slug: trustedshops-public
orb-version: dev:${CIRCLE_SHA1}
publish:
executor: circleci-cli/default
steps:
- upload_for_publish:
orb-name: trigger-pipeline
orb-slug: trustedshops-public
orb-version: ${CIRCLE_TAG}

workflows:
continious:
jobs:
- orb-tools/lint:
<<: *filter_all
- orb-tools/pack:
<<: *filter_all
- shellcheck/check:
dir: ./src/scripts
exclude: SC2148
<<: *filter_all
- publish-dev:
<<: *require_tests
context:
- circleci-orbs
- publish:
<<: *require_tests
<<: *filter_tags
context:
- circleci-orbs
- semantic-release/with-changelog-github-config:
name: semantic-release
<<: *require_tests
filters:
branches:
only:
- main
context:
- semantic-release
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @trustedshops-public/circleci-orbs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
fail_fast: true
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-json
- id: check-merge-conflict
- id: check-yaml
exclude: .circleci/config.yml
- id: detect-private-key
- id: check-symlinks
- id: check-vcs-permalinks
- id: trailing-whitespace
args:
- --markdown-linebreak-ext=md
- id: mixed-line-ending
args:
- --fix=lf
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-toml
- id: check-xml
- id: fix-byte-order-marker
- id: destroyed-symlinks

- repo: https://github.com/syntaqx/git-hooks
rev: v0.0.17
hooks:
- id: circleci-config-validate
- id: shellcheck
args: [ '-e2148' ]
6 changes: 6 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends: relaxed

rules:
line-length:
max: 200
allow-non-breakable-inline-mappings: true
46 changes: 46 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributing to our CircleCI orb trigger-pipeline
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:

- Reporting a bug
- Discussing the current state of the configuration
- Submitting a fix
- Proposing new features
- Becoming a maintainer

## We Develop with GitHub
We use GitHub to host code, to track issues and feature requests, as well as accept pull requests.

## We Use [CircleCI](https://circleci.com/product/), So All Code Changes Happen Through Pull Requests
Pull requests are the best way to propose changes to the codebase (we use [CircleCI](https://circleci.com/product/)). We actively welcome your pull requests:

1. Fork the repo and create your branch from `main`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the tests pass.
5. Make sure your code and commit lints.
6. Issue that pull request!

## Any contributions you make will be under the MIT License
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](https://opensource.org/licenses/MIT) that covers the project. Feel free to contact the maintainers if that's a concern.

## Report bugs using GitHub's issues
We use GitHub issues to track public bugs. Report a bug by opening a new issue, it's that easy!

## Write bug reports with detail, background, and sample code

**Great Bug Reports** tend to have:

- A quick summary and/or background
- Steps to reproduce
- Be specific!
- Give sample code if you can.
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)

People *love* thorough bug reports. I'm not even kidding.

To make your life easier there is also a handy template available so feel free to use it.

## License
By contributing, you agree that your contributions will be licensed under its MIT License.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 TrustedShops

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
circleci-orb-trigger-pipeline
===
[![GitHub License](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/trustedshops-public/trigger-pipeline/blob/main/LICENSE)
[![pre-commit](https://img.shields.io/badge/%E2%9A%93%20%20pre--commit-enabled-success)](https://pre-commit.com/)
[![CircleCI Build Status](https://circleci.com/gh/trustedshops-public/circleci-orb-trigger-pipeline.svg?style=shield "CircleCI Build Status")](https://circleci.com/gh/trustedshops-public/circleci-orb-trigger-pipeline)
[![CircleCI Orb Version](https://badges.circleci.com/orbs/trustedshops-public/trigger-pipeline.svg)](https://circleci.com/orbs/registry/orb/trustedshops-public/trigger-pipeline)

CircleCI orb to trigger other CircleCI pipelines

## Resources

[CircleCI Orb Registry Page](https://circleci.com/orbs/registry/orb/trustedshops-public/trigger-pipeline) - The official registry page of this
orb for all versions, executors, commands, and jobs described.

[CircleCI Orb Docs](https://circleci.com/docs/2.0/orb-intro/#section=configuration) - Docs for using and creating
CircleCI Orbs.

### How to Contribute

We welcome [issues](https://github.com/trustedshops-public/circleci-orb-trigger-pipeline/issues) to
and [pull requests](https://github.com/trustedshops-public/circleci-orb-trigger-pipeline/pulls) against this repository!

### Commit Message Convention

This repository follows [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)

#### Format

`<type>(optional scope): <description>`
Example: `feat(pre-event): Add speakers section`

#### 1. Type

Available types are:

- feat → Changes about addition or removal of a feature. Ex: `feat: Add table on landing page`
, `feat: Remove table from landing page`
- fix → Bug fixing, followed by the bug. Ex: `fix: Illustration overflows in mobile view`
- docs → Update documentation (README.md)
- style → Updating style, and not changing any logic in the code (reorder imports, fix whitespace, remove comments)
- chore → Installing new dependencies, or bumping deps
- refactor → Changes in code, same output, but different approach
- ci → Update github workflows, husky
- test → Update testing suite, cypress files
- revert → when reverting commits
- perf → Fixing something regarding performance (deriving state, using memo, callback)
- vercel → Blank commit to trigger vercel deployment. Ex: `vercel: Trigger deployment`

#### 2. Optional Scope

Labels per page Ex: `feat(pre-event): Add date label`

*If there is no scope needed, you don't need to write it*

#### 3. Description

Description must fully explain what is being done.

Add BREAKING CHANGE in the description if there is a significant change.

**If there are multiple changes, then commit one by one**

- After colon, there are a single space Ex: `feat: Add something`
- When using `fix` type, state the issue Ex: `fix: File size limiter not working`
- Use imperative, dan present tense: "change" not "changed" or "changes"
- Use capitals in front of the sentence
- Don't add full stop (.) at the end of the sentence

### Publish new release

Commit according to semantic release spec above and let CircleCI (and semantic-release) do the magic.
8 changes: 8 additions & 0 deletions src/@orb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2.1

description: |
CircleCI orb to trigger other CircleCI pipelines
display:
home_url: "https://github.com/trustedshops-public/circleci-orb-trigger-pipeline"
source_url: "https://github.com/trustedshops-public/circleci-orb-trigger-pipeline"
17 changes: 17 additions & 0 deletions src/commands/create-trigger-pipeline-script.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
description: >
Create python script for triggering CircleCI pipelines
parameters:
destination:
default: /usr/local/bin/circleci-trigger-pipeline
description: Path to use for the script
type: string

steps:
- run:
name: Populate script name as env variable
command: |
echo 'export CIRCLECI_TRIGGER_PIPELINE_SCRIPT_PATH="<<parameters.destination>>"' >> $BASH_ENV
- run:
name: Create python script
command: <<include(scripts/create-trigger-pipeline-script.sh)>>
43 changes: 43 additions & 0 deletions src/commands/trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
description: >
Trigger CircleCI pipeline
parameters:
branch:
type: string
description: Branch to trigger pipeline for
default: main
build-parameters:
type: string
description: Build parameters in format key=value, separated by spaces
default: ""
vcs:
type: string
description: VCS Provider that is used in the target project
default: "github"
circleci-url:
type: string
description: CircleCI url to use, without trailing slash
default: "https://circleci.com"
circleci-token:
type: env_var_name
description: Name of the environment variable containing the CircleCI token to use for api calls
default: CIRCLE_TOKEN
slug:
type: string
description: Slug for org/username and project separated by slash
script:
type: string
description: Script path to use for execution
default: circleci-trigger-pipeline

steps:
- run:
name: Trigger pipeline for <<parameters.slug>> on branch <<parameters.branch>>
command: |
<<parameters.script>> \
--branch <<parameters.branch>> \
--build-parameters <<parameters.build-parameters>> \
--vcs <<parameters.vcs>> \
--circleci-url <<parameters.circleci-url>> \
--circleci-token $<<parameters.circleci-token>> \
--slug <<parameters.slug>>
21 changes: 21 additions & 0 deletions src/examples/job-trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
description: Job for triggering a CircleCI pipeline also using github in the same org as the current project.
usage:
version: 2.1
orbs:
trigger-pipeline: trustedshops-public/trigger-pipeline@<version>
workflows:
version: 2
continious:
jobs:
- trigger-pipeline/trigger:
name: trigger-dev-deployment
branch: master
build-parameters: service=booking-api stage=dev triggering_workflow=${CIRCLE_WORKFLOW_ID}
circleci-token: CIRCLE_TOKEN_ANSIBLE_API_DEPLOYMENT
slug: ${CIRCLE_PROJECT_USERNAME}/ansible-api-deployment
script: <<parameters.script>>
context:
- ansible-api-deployment
filters:
branches:
only: [ main ]
13 changes: 13 additions & 0 deletions src/executors/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
description: >
Default executor
docker:
- image: 'cimg/python:<<parameters.tag>>'

parameters:
tag:
default: "3.10"
description: >
Pick a specific circleci/python image variant:
https://hub.docker.com/r/cimg/python/tags
type: string
Loading

0 comments on commit c367c26

Please sign in to comment.