-
Notifications
You must be signed in to change notification settings - Fork 39
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,13 +13,16 @@ permissions: | |
jobs: | ||
package-filter: | ||
name: Filter for updated package | ||
if: github.repository == 'polusai/polus-plugins' | ||
uses: ./.github/workflows/package-filter.yml | ||
|
||
package-release: | ||
name: Bump release version of updated package | ||
name: Release "${{ matrix.package_name }}" | ||
if: github.repository == 'polusai/polus-plugins' | ||
runs-on: ubuntu-latest | ||
needs: package-filter | ||
strategy: | ||
matrix: ${{fromJson(needs.package-filter.outputs.matrix)}} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
@@ -31,28 +34,27 @@ jobs: | |
run: | | ||
python -m pip install --upgrade pip | ||
pip install bump2version | ||
- name: Bump Version on all updated packages | ||
- name: Bump Version | ||
run: | | ||
CUR_DIR=$(pwd) | ||
for package_dir in ${{ needs.package-filter.outputs.package_dirs }} | ||
do | ||
cd "$CUR_DIR/$package_dir" | ||
bump2version release --no-commit | ||
done | ||
cd "$CUR_DIR" | ||
cd "${{ matrix.package_dir }}" | ||
bump2version release --no-commit | ||
- name: Commit and push all changed files | ||
env: | ||
CI_COMMIT_AUTHOR: Continuous Integration | ||
run: | | ||
PKG_NAMES="" | ||
for package_dir in ${{ needs.package-filter.outputs.package_dirs }} | ||
do | ||
PKG_NAMES="$PKG_NAMES $(basename $package_dir)" | ||
done | ||
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}" | ||
git config --global user.email "[email protected]" | ||
git commit -a -m "build: Bumped release version for $PKG_NAMES" | ||
git commit -a -m "build: Bumped release version for ${{ matrix.package_name }}" | ||
git push | ||
docker: | ||
name: Build Docker images | ||
if: github.repository == 'polusai/polus-plugins' | ||
needs: [package-filter, package-release] | ||
uses: ./.github/workflows/docker.yml | ||
with: | ||
matrix: ${{ needs.package-filter.outputs.matrix }} | ||
push: true | ||
secrets: | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_TOKEN }} |
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