Skip to content
Latchkey

Publish Docker image for Artillery workflow (artilleryio/artillery)

The Publish Docker image for Artillery workflow from artilleryio/artillery, explained and optimized by Latchkey.

B

CI health: B - good

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: artilleryio/artillery.github/workflows/docker-publish-artillery.ymlLicense MPL-2.0View source

What it does

This is the Publish Docker image for Artillery workflow from the artilleryio/artillery repository, a real project running GitHub Actions. It is shown here with attribution under its MPL-2.0 license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Publish Docker image for Artillery

on:
  workflow_dispatch:
    # this will override the latest image, so only trigger when you want to publish a new version
    inputs:
      COMMIT_SHA:
        description: 'Commit SHA'
        required: true
        type: string
  workflow_call:
    inputs:
      COMMIT_SHA:
        description: 'Commit SHA'
        required: true
        type: string
    secrets:
      DOCKER_USERNAME:
        description: 'Docker Hub username'
        required: true
      DOCKER_PASSWORD:
        description: 'Docker Hub password'
        required: true

jobs:
  push_to_registry:
    name: Push Docker image to Docker Hub
    runs-on: blacksmith-4vcpu-ubuntu-2404
    steps:
      - name: Check out the repo
        uses: actions/checkout@v3
        with:
          ref: ${{ inputs.COMMIT_SHA || null }}
          fetch-depth: 0

      - name: Get Artillery version
        run: |
          echo "ARTILLERY_VERSION=$(node -e 'console.log(require("./packages/artillery/package.json").version)')" >> $GITHUB_ENV

      - name: Log in to Docker Hub
        uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: Extract metadata (tags, labels) for Docker
        id: meta
        uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
        with:
          images: artilleryio/artillery
          tags: |
            type=semver,pattern={{version}},value=${{env.ARTILLERY_VERSION}}
            type=raw,value=latest

      - name: Build and push Docker image
        uses: useblacksmith/build-push-action@v2
        with:
          context: ./packages/artillery
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Publish Docker image for Artillery
 
on:
  workflow_dispatch:
    # this will override the latest image, so only trigger when you want to publish a new version
    inputs:
      COMMIT_SHA:
        description: 'Commit SHA'
        required: true
        type: string
  workflow_call:
    inputs:
      COMMIT_SHA:
        description: 'Commit SHA'
        required: true
        type: string
    secrets:
      DOCKER_USERNAME:
        description: 'Docker Hub username'
        required: true
      DOCKER_PASSWORD:
        description: 'Docker Hub password'
        required: true
 
jobs:
  push_to_registry:
    timeout-minutes: 30
    name: Push Docker image to Docker Hub
    runs-on: blacksmith-4vcpu-ubuntu-2404
    steps:
      - name: Check out the repo
        uses: actions/checkout@v3
        with:
          ref: ${{ inputs.COMMIT_SHA || null }}
          fetch-depth: 0
 
      - name: Get Artillery version
        run: |
          echo "ARTILLERY_VERSION=$(node -e 'console.log(require("./packages/artillery/package.json").version)')" >> $GITHUB_ENV
 
      - name: Log in to Docker Hub
        uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
 
      - name: Extract metadata (tags, labels) for Docker
        id: meta
        uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
        with:
          images: artilleryio/artillery
          tags: |
            type=semver,pattern={{version}},value=${{env.ARTILLERY_VERSION}}
            type=raw,value=latest
 
      - name: Build and push Docker image
        uses: useblacksmith/build-push-action@v2
        with:
          context: ./packages/artillery
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
 

What changed

1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow