Reusing workflows avoids duplication
Closed this issue · 2 comments
jongwooo commented
What would you like to be added
base-docker-publish.yml
name: Base Docker Publish
on:
workflow_call:
inputs:
command:
description: make command to run
required: true
default: docker # or docker-latest
type: string
jobs:
# ...
- name: Build Image
env:
COMMAND: ${{ github.event.inputs.command }}
run: make $COMMAND
docker-publish.yml
name: docker-publish
on:
release:
types: [published]
jobs:
build:
uses: ./.github/workflows/base-docker-publish.yml
with:
command: docker
docker-publish-latest.yml
name: docker-publish-latest
on:
push:
branches:
- main
jobs:
build:
uses: ./.github/workflows/base-docker-publish.yml
with:
command: docker-latest
Why is this needed
Of the workflows, docker-publish.yml
and docker-publish-latest.yml
consist of the exact same workflow except for the last command. (make docker
or make docker-latest
) By abstracting into reusable workflows, we can simplify redundant workflows.
See also https://docs.github.com/en/actions/using-workflows/reusing-workflows , https://blog.outsider.ne.kr/1591
hackerwins commented
@jongwooo
Thanks for your reporting. Could you send a PR for this?
jongwooo commented
@hackerwins Sure :)