Update .github/workflows/docker.yaml

This commit is contained in:
Zakary Timson 2024-02-06 13:56:36 +00:00
parent c1fa83d47c
commit 9056c7c862

View File

@ -1,76 +1,91 @@
name: Build & Publish Dockerfile
on:
workflow_call:
inputs:
repository:
type: string
required: true
description: Git repository URL
dockerfile:
type: string
required: false
description: Name or path to Dockerfile
default: Dockerfile
registry:
type: string
required: false
description: Docker registry FQDN
default: ${{github.server_url}}
user:
type: string
required: false
description: Docker user
default: ${{github.repository_owner}}
pass:
type: string
required: true
description: User password
name:
type: string
required: false
description: Docker container name
default: ${{github.repository}}
tag:
type: string
required: false
description: Docker tag that will be added to image
default: ${{github.ref_name}}
jobs:
docker:
name: Build & Publish Dockerfile
runs-on: ubuntu-latest
container: docker
steps:
- name: Clone Repository
uses: ztimson/actions/clone@develop
with:
url: ${{inputs.repository}}
- name: Build Docker Image
uses: ztimson/actions/docker/build@develop
with:
registry: ${{inputs.registry}}
name: ${{inputs.name}}
tag: ${{inputs.tag}}
dockerfile: ${{inputs.dockerfile}}
- name: Push Docker Image
uses: ztimson/actions/docker/push@develop
with:
registry: ${{inputs.registry}}
user: ${{inputs.user}}
pass: ${{inputs.pass}}
name: ${{inputs.name}}
tag: ${{inputs.tag}}
- name: Tag as Latest
uses: ztimson/actions/docker/push@develop
if: ${{inputs.tag}} != latest && ${{github.ref_name}} == (git symbolic-ref refs/remotes/origin/HEAD --short | cut -c 7)
with:
registry: ${{inputs.registry}}
user: ${{inputs.user}}
pass: ${{inputs.pass}}
name: ${{inputs.name}}
tag: latest
name: Build & Publish Dockerfile
on:
workflow_call:
inputs:
repository:
type: string
required: true
description: Git repository URL
dockerfile:
type: string
required: false
description: Name or path to Dockerfile
default: Dockerfile
registry:
type: string
required: false
description: Docker registry FQDN
default: ${{github.server_url}}
user:
type: string
required: false
description: Docker user
default: ${{github.repository_owner}}
pass:
type: string
required: true
description: User password
name:
type: string
required: false
description: Docker container name
default: ${{github.repository}}
tag:
type: string
required: false
description: Docker tag that will be added to image
default: ${{github.ref_name}}
jobs:
docker:
name: Build & Publish Dockerfile
runs-on: ubuntu-latest
container: docker
steps:
- name: Clone Repository
uses: ztimson/actions/clone@develop
with:
url: ${{inputs.repository}}
- name: Get Version Number
run: [[ -f package.json ]] && echo "VERSION=$(cat package.json | grep version | grep -Eo ':.+' | grep -Eo '[[:alnum:]\.\/\-]+')" >> $GITHUB_ENV
- name: Build Docker Image
uses: ztimson/actions/docker/build@develop
with:
registry: ${{inputs.registry}}
name: ${{inputs.name}}
tag: ${{inputs.tag}}
dockerfile: ${{inputs.dockerfile}}
- name: Push as ${{inputs.tag}}
uses: ztimson/actions/docker/push@develop
with:
registry: ${{inputs.registry}}
user: ${{inputs.user}}
pass: ${{inputs.pass}}
name: ${{inputs.name}}
tag: ${{inputs.tag}}
- name: Push as ${{env.VERSION}}
uses: ztimson/actions/docker/push@develop
if: ${{env.VERSION}}
with:
from: "${{inputs.registry}}/${{inputs.name}}/${{inputs.tag}}"
registry: ${{inputs.registry}}
user: ${{inputs.user}}
pass: ${{inputs.pass}}
name: ${{inputs.name}}
tag: ${{env.VERSION}}
- name: Push as Latest
uses: ztimson/actions/docker/push@develop
if: ${{inputs.tag}} != latest && ${{github.ref_name}} == (git symbolic-ref refs/remotes/origin/HEAD --short | cut -c 7)
with:
from: "${{inputs.registry}}/${{inputs.name}}/${{inputs.tag}}"
registry: ${{inputs.registry}}
user: ${{inputs.user}}
pass: ${{inputs.pass}}
name: ${{inputs.name}}
tag: latest