Skip to content

boromir674/automated-workflows

Repository files navigation

CI/CD Workflows

CI Status Read the Docs License

Reusable Workflows for CI/CD Pipelines, implemented in Github Actions.

Live Documentation at https://automated-workflows.readthedocs.io.

Reusable Workflows

Note

See the API References in the Documentation for all the Reusable Workflows.

Git Ops Processes

  • release-me: Ship your Branch to main with 2 Steps/PRs

Note

See the how-to Guides for implementing your Git Ops Processes.

Quickstart

Docker

Continuously Publish to Dockerhub using docker.yml.

Prerequisites

  • GitHub account.
  • Access to a repository.
  • Passing a proper DOCKER_USER from context
  • Passing a proper DOCKER_PASSWORD from secrets

Use Case 1: CI/Continuous Deployment

"We publish to Dockerhub only Tested Builds"

Quick-start
graph LR
workflow_triggered("CI Start") --> rt{"Do QA?"}
rt -- Yes --> cit
cit["Run Tests"] --> ifpass{"Passed?"}
ifpass -- "Yes" --> run_docker["Publish Docker"]
ifpass -- "No" --> do_not_publish_broken_build["Decline Publish"]
rt -- No --> do_not_publish_broken_build
Loading
env:
  DO_QA: true

jobs:
  build_n_test:
    runs-on: ubuntu-latest
    if: always() && ${{ env.DO_QA == 'true' }}
    steps:
      - run: echo "Build Code and run Tests"

  call_docker_job:
    needs: build_n_test
    uses: boromir674/automated-workflows/.github/workflows/docker.yml@test
    with:
      DOCKER_USER: ${{ vars.DOCKER_USER }}
      acceptance_policy: 2
      image_slug: "my_app_name"
      image_tag: "1.0.0"
      tests_pass: ${{ needs.build_n_test.result == 'success' }}
      tests_run: ${{ !contains(fromJSON('["skipped", "cancelled"]'), needs.build_n_test.result) }}
    secrets:
      DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

Use Case 2: CI/Continuous Delivery

  • "Publish to Dockerhub Builds bearing a 'Tests Passed' or a 'Tests Skipped'"
Quick-start
  • Not tested builds (ie when CI Test Job is skipped for any reason), are still treated as eligible for Docker Publish.
  • Useful to trigger Docker Job, without waiting for Tests.
graph LR
workflow_triggered("CI Start") --> rt{"Run QA?"}
rt -- Yes --> cit
cit["Run Tests"] --> ifpass{"Passed?"}
ifpass -- "Yes" --> run_docker["Publish Docker"]
ifpass -- "No" --> do_not_publish_broken_build["Decline Publish"]
rt -- No --> run_docker
Loading
env:
  DO_QA: false

jobs:
  build_n_test:
    runs-on: ubuntu-latest
    if: always() && ${{ env.DO_QA == 'true' }}
    steps:
      - run: echo "Build Code and run Tests"

  call_docker_job:
    needs: build_n_test
    uses: boromir674/automated-workflows/.github/workflows/docker.yml@test
    with:
      DOCKER_USER: ${{ vars.DOCKER_USER }}
      acceptance_policy: 3
      image_slug: "my_app_name"
      image_tag: "1.0.0"
      tests_pass: ${{ needs.build_n_test.result == 'success' }}
      tests_run: ${{ !contains(fromJSON('["skipped", "cancelled"]'), needs.build_n_test.result) }}
    secrets:
      DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

License