Skip to content

CD

CD #100

Workflow file for this run

name: 'CD'
on:
workflow_dispatch:
push:
branches:
- master
- staging
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
prepare:
name: 'Prepare'
uses: rfcx/cicd/.github/workflows/notify-prepare.yaml@master
with:
repo: ingest-service
workflow-id: cd.yaml
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
configure:
name: 'Configure'
runs-on: ubuntu-latest
needs: [prepare]
outputs:
namespace: ${{ steps.configuration.outputs.namespace }}
steps:
- name: 'Conditional environment'
id: configuration
run: |
if [[ "${{ needs.prepare.outputs.branch-name }}" == "master" ]]; then
echo "::set-output name=namespace::production"
elif [[ "${{ needs.prepare.outputs.branch-name }}" == "staging" ]]; then
echo "::set-output name=namespace::staging"
else
echo "::set-output name=namespace::testing"
fi
build:
name: 'Build'
needs: [prepare, configure]
uses: rfcx/cicd/.github/workflows/ecr-build-push.yaml@master
with:
dockerfile: build/Dockerfile
targets: "[\"ingest-service\"]"
tag-environment: ${{ needs.configure.outputs.namespace }}
tag-latest: ${{ needs.configure.outputs.namespace == 'production' }}
secrets:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
deploy:
name: 'Deploy'
needs: [build, configure]
uses: rfcx/cicd/.github/workflows/k8s-deploy.yaml@master
with:
tag: ${{ needs.build.outputs.unique-tag }}
namespace: ${{ needs.configure.outputs.namespace }}
secrets:
kube-config: ${{ secrets.KUBE_CONFIG_SUPER }}
notify:
name: 'Notify'
if: ${{ always() }}
needs: [prepare, build, deploy]
uses: rfcx/cicd/.github/workflows/notify-send.yaml@master
with:
repo: ingest-service
branch-name: ${{ needs.prepare.outputs.branch-name }}
workflow-id: cd.yaml
previous-run-id: ${{ needs.prepare.outputs.previous-run-id }}
status: ${{ needs.deploy.result }}
always: true
notification-title: 'CD: Ingest Service'
notification-footer: "Build: ${{ needs.build.result || 'n/a' }} | Deploy: ${{ needs.deploy.result || 'n/a' }}"
notification-success-statement: '{0} deployed the build!'
secrets:
slack-webhook: ${{ secrets.SLACK_ALERT_COREDT_WEBHOOK }}
github-token: ${{ secrets.GITHUB_TOKEN }}