Leading-edge DevOps automation plus GitOps deployments
slides: autodeploy.bretfisher.com
–
Let’s focus on wordsmith-web for now
wordsmith-webNew workflow, then click setup a workflow yourself.github/workflows/docker-build.ymltags to our repo (last line) ghcr.io/<orgname>/wordsmith-web:latest<orgname> must be lowercase to work with Docker!
:latestorg.opencontainers.image.title=wordsmith-api
org.opencontainers.image.source=https://github.com/MostlyDevOps/wordsmith-api
org.opencontainers.image.version=gha-4715332302
org.opencontainers.image.created=2023-04-16T21:16:33.149Z
org.opencontainers.image.revision=f217725e1bf9e1032debb15df43b06513907d58bMore automation means you need more guardrails
main branch protection ruleAvoid multiple commits in the same branch/PR from running at the same time
Add this at workflow level, before jobs, in every workflow
# cancel any previously-started, yet still active runs of this workflow on the same branch
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: trueYou can do this in the extra credit slides later
Let’s add a Dependabot config to our wordsmith-web repo
.github folder called dependabot.yml---
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"Then you’ll see PRs like this:

This only works for image tags that use semver tags
package-ecosystem to the dependabot.yml file - package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "[docker] "Then you’ll see PRs like this:

This also works for Kubernetes and Helm! Repeat the above YAML for each directory you want to update.
Note: Dependabot can update many dependencies, check it out
Extra, Extra Credit: Watch my Super-Linter walkthrough live stream
wordsmith-web repo, go to the Actions tab.github and put workflows in there
actions repoactions.github/dependabot.yml file with this content:version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"Note: If the repo was private, this setting would show up. We would need to change it:
Settings > Actions > General > Access 
Imagine all these being centrally controlled and automated for all software repos in your org
.github/workflows that you want to reuse elsewhere on:workflow_call event to the workflowinputs and secrets to that event input and secret values into the workflow stepsinputs and secrets to the calling workflowswordsmith-web repo.github/workflows/call-trivy.yml and paste this in<org>. Then change <pr-branch-name> to the branch you just created in the actions repodraft, because you’ll change it to main branch before mergingname: Call Trivy
on:
push:
branches: [main]
pull_request:
jobs:
scan:
name: Scan
uses: <org>/actions/.github/workflows/reusable-trivy.yml@<pr-branch-name>Question 1: What workflow will you likely build first in your work projects?
Question 2: What workflow would most impress your boss?
After you speak, pick the next raised hand to speak
with and secretsjobs:
call-docker-build:
name: Call Docker Build
uses: bretfisher/docker-build-workflow/.github/workflows/reusable-docker-build.yaml@main
secrets:
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
with:
dockerhub-enable: true
image-names: ghcr.io/${{ github.repository }}
tag-rules: |
type=ref,event=pr
type=raw,value=gha-${{ github.run_id }}Reusable workflows accept data via inputs
inputs array to our reusable workflow on:workflow_call: event${{ inputs.<input-name> }}with and secrets key:values to our calling workflowlatest We’ll need to ensure our Docker Build creates a unique image tag for each PR commit
Also, we’ll need to wait for Docker Build to finish before trying to scan
GITHUB_TOKEN and these permsname: Docker Build
on:
push:
branches:
- main
pull_request:
jobs:
call-docker-build:
name: Call Docker Build
uses: mostlydevops/actions/.github/workflows/reusable-docker-build.yaml@main
permissions:
packages: write
pull-requests: write
with:
image-name: ghcr.io/mostlydevops/wordsmith-webImagine all these being centrally controlled and automated for all software repos in your org
web and api?uses: path for the reusable workflowsecrets: and with: were empty arrays and invalid YAML. Comment them outgithub.com/orgs/<org-name>/packages shows two images stable-20230714-b3cc954latest and stable-<date>-<sha> images to deploy)
Which Argo CD setup design do you think you’ll use?