-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0363ec3
commit ecea880
Showing
3 changed files
with
114 additions
and
84 deletions.
There are no files selected for viewing
159 changes: 76 additions & 83 deletions
159
.github/actions/build-test-and-deploy/build_docker/action..yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,81 @@ | ||
name: Build docker image & push to registry. | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
repository_name: | ||
description: Repository name | ||
required: true | ||
type: string | ||
docker_registry: | ||
description: Docker registry | ||
required: true | ||
type: string | ||
registry_org: | ||
description: Docker registry organisation | ||
required: true | ||
type: string | ||
additional_docker_tag: | ||
description: Additional docker tag that can be used to specify stable tags | ||
required: false | ||
type: string | ||
push: | ||
description: Push docker image to registry flag | ||
required: true | ||
type: boolean | ||
app_version: | ||
description: App version | ||
required: true | ||
type: string | ||
docker_registry_username: | ||
description: Docker registry username | ||
required: true | ||
type: string | ||
docker_registry_token: | ||
description: Docker registry username | ||
required: true | ||
type: string | ||
git_head_ref: | ||
description: git head ref | ||
required: true | ||
type: string | ||
git_ref_name: | ||
description: git branch name | ||
required: true | ||
type: string | ||
inputs: | ||
repository_name: | ||
description: Repository name | ||
required: true | ||
type: string | ||
docker_registry: | ||
description: Docker registry | ||
required: true | ||
type: string | ||
registry_org: | ||
description: Docker registry organisation | ||
required: true | ||
type: string | ||
additional_docker_tag: | ||
description: Additional docker tag that can be used to specify stable tags | ||
required: false | ||
type: string | ||
push: | ||
description: Push docker image to registry flag | ||
required: true | ||
type: boolean | ||
app_version: | ||
description: App version | ||
required: true | ||
type: string | ||
HMPPS_QUAYIO_USER: | ||
description: Docker registry username | ||
required: false | ||
type: string | ||
HMPPS_QUAYIO_TOKEN: | ||
description: Docker registry token | ||
required: false | ||
type: string | ||
git_head_ref: | ||
description: Github source branch ref | ||
required: false | ||
type: string | ||
git_branch_ref: | ||
description: Github source branch name | ||
required: false | ||
type: string | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
docker_build: | ||
name: Build docker image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: docker/setup-qemu-action@v2 | ||
- uses: docker/setup-buildx-action@v2 | ||
- name: Docker login if Docker registry is quay.io | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ inputs.docker_registry }} | ||
username: ${{ inputs.docker_registry_username }} | ||
password: ${{ inputs.docker_registry_token }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: docker/setup-qemu-action@v2 | ||
- uses: docker/setup-buildx-action@v2 | ||
- name: Docker login if Docker registry is quay.io | ||
if: ${{ inputs.docker_registry == 'quay.io' }} | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ inputs.docker_registry }} | ||
username: ${{ inputs.HMPPS_QUAYIO_USER }} | ||
password: ${{ inputs.HMPPS_QUAYIO_TOKEN }} | ||
|
||
- name: Docker login if Docker registry is ghcr.io | ||
if: ${{ inputs.docker_registry == 'ghcr.io' }} | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ inputs.docker_registry }} | ||
username: ${{ input.docker_registry_username }} | ||
password: ${{ input.input.docker_registry_token }} | ||
- name: Docker login if Docker registry is ghcr.io | ||
if: ${{ inputs.docker_registry == 'ghcr.io' }} | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ inputs.docker_registry }} | ||
username: ${{ github.actor }} | ||
password: ${{ github.token }} | ||
|
||
- name: Build Docker images | ||
uses: docker/build-push-action@v4 | ||
with: | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
context: . | ||
push: ${{ inputs.push }} | ||
provenance: false | ||
build-args: | | ||
"BUILD_NUMBER=${{ inputs.app_version }}" | ||
"GIT_REF=$${{ inputs.git_head_ref }}" | ||
"GIT_BRANCH=$${{ inputs.git_ref_name }}" | ||
tags: | | ||
${{ inputs.docker_registry}}/${{ inputs.registry_org }}/${{ inputs.repository_name }}:latest | ||
${{ inputs.docker_registry}}/${{ inputs.registry_org }}/${{ inputs.repository_name }}:${{ inputs.app_version }} | ||
- name: Build Docker images | ||
uses: docker/build-push-action@v4 | ||
with: | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
context: . | ||
push: ${{ inputs.push }} | ||
provenance: false | ||
build-args: | | ||
"BUILD_NUMBER=${{ inputs.app_version }}" | ||
"GIT_REF=$${{ inputs.git_head_ref }}" | ||
"GIT_BRANCH=${{ inputs.git_branch_ref }}" | ||
tags: | | ||
${{ inputs.docker_registry}}/${{ inputs.registry_org }}/${{ github.event.repository.name }}:latest | ||
${{ inputs.docker_registry}}/${{ inputs.registry_org }}/${{ github.event.repository.name }}:${{ inputs.app_version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters