DevOps Classroom notes 24/Jul/2026

Workflow_call

name: docker_workflow

on: 
  workflow_call:
    inputs:
      dockerimage:
       default: spring
       type: string
       required: true
      DOCKERHUB_USERNAME:
        type: string
        default: ramqt2205
        required: true
jobs:
  build_and_publish:
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v7
        with:
          fetch-depth: 0

      - name: install docker
        uses: docker/setup-buildx-action@v4

      - name:  login dockerhub
        uses: docker/login-action@v4
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PAT }}

      - name: buid and publish image main
        if: ${{ github.ref_name == 'main' }}
        uses: docker/build-push-action@v7
        with:
          push: true
          tags: ${{ inputs.DOCKERHUB_USERNAME }}/${{ inputs.dockerimage }}:${{ github.run_number }}

      - name: buid and publish image main
        if: ${{ github.ref_name != 'main' }}
        uses: docker/build-push-action@v7
        with:
          push: true
          tags: ${{ inputs.DOCKERHUB_USERNAME }}/${{ inputs.dockerimage }}-snapshot:${{ github.run_number }}

Call workflow

name: call docker workflow

on:
  push:
    branches: '*'

jobs:
  call-docker-build:
    uses: direct-devops/actions/.github/workflows/docker.yaml@main
    with:
      dockerimage: spring-petclinic # ${{ github.repository.name }}
      DOCKERHUB_USERNAME: ramqt2205
    secrets: inherit

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%