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