-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: Added Docker workflow and switched to matrix strategy (#503)
* ci: using matrix strategy * ci: added docker workflow * ci: restricting release workflow to polusai repo only * ci: fixing docker image check
- Loading branch information
Showing
4 changed files
with
139 additions
and
53 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Docker Build and Push | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
matrix: | ||
description: 'JSON-encoded matrix' | ||
required: true | ||
type: string | ||
push: | ||
description: 'Whether to push the image to Docker Hub' | ||
required: true | ||
type: boolean | ||
secrets: | ||
DOCKER_USERNAME: | ||
description: 'Docker Hub username' | ||
required: true | ||
DOCKER_PASSWORD: | ||
description: 'Docker Hub password' | ||
required: true | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
docker: | ||
name: Docker "${{ matrix.package_name }}" | ||
strategy: | ||
matrix: ${{fromJson(inputs.matrix)}} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Get | Docker Tag | ||
id: docker_tag | ||
run: | | ||
package_dir="${{ matrix.package_dir }}" | ||
version=$(cat ${package_dir}/VERSION) | ||
tag=polusai/${{ matrix.package_name }}:${version} | ||
echo "tag=${tag}" >> $GITHUB_OUTPUT | ||
- name: Setup | Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login | DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Check | Image exists | ||
run: | | ||
tag=${{ steps.docker_tag.outputs.tag }} | ||
docker pull ${tag} > /dev/null \ | ||
&& $(echo "::error::${tag} already exists on DockerHub" && exit 1) \ | ||
|| echo "success" | ||
- name: Publish | Docker Image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: "{{defaultContext}}:${{ matrix.package_dir }}" | ||
push: ${{ inputs.push }} | ||
tags: ${{ steps.docker_tag.outputs.tag }} |
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
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