Merge pull request #10 from MILO-ML/bug/fix-cd-issues #1
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
name: Deploy to Docker Hub on merge | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Checkout Processor Tools | |
uses: actions/checkout@v4 | |
with: | |
repository: MILO-ML/Processor-Tools | |
path: preprocessor | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: '5.x' | |
- name: Run GitVersion | |
id: gitversion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
useConfigFile: false | |
- name: Update package version | |
run: | | |
sed -i.bak "s|\"version\": \"[0-9\.]*\"|\"version\": \"${{ steps.gitversion.outputs.semVer }}\"|" package.json | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Cache UI Dependencies | |
id: cache_ui | |
uses: actions/cache@v4 | |
with: | |
path: ui/node_modules | |
key: ${{ runner.os }}-ui-${{ hashFiles('ui/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-ui- | |
- name: Cache Docs Dependencies | |
id: cache_docs | |
uses: actions/cache@v4 | |
with: | |
path: docs/node_modules | |
key: ${{ runner.os }}-docs-${{ hashFiles('docs/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-docs- | |
- name: Cache Preprocessor Dependencies | |
id: cache_pp | |
uses: actions/cache@v4 | |
with: | |
path: preprocessor/node_modules | |
key: ${{ runner.os }}-preprocessor-${{ hashFiles('preprocessor/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-preprocessor- | |
- name: Install UI dependencies | |
if: steps.cache_ui.outputs.cache-hit != 'true' | |
run: npm --prefix ui install | |
- name: Install Docs dependencies | |
if: steps.cache_docs.outputs.cache-hit != 'true' | |
run: npm --prefix docs install | |
- name: Install Preprocessor dependencies | |
if: steps.cache_pp.outputs.cache-hit != 'true' | |
run: npm --prefix preprocessor install | |
- name: Build AutoML UI | |
run: npm --prefix ui run build-docker | |
- name: Build Documentation | |
run: NODE_OPTIONS=--openssl-legacy-provider npm --prefix docs run build | |
- name: Build Preprocessor UI | |
run: NODE_OPTIONS=--openssl-legacy-provider npm --prefix preprocessor run milo-build | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Set Tag | |
run: | | |
if [ "${GITHUB_REF##*/}" == "master" ]; then | |
echo "TAG=latest" >> $GITHUB_ENV | |
else | |
echo "TAG=beta" >> $GITHUB_ENV | |
fi | |
- name: Build All-in-One Docker Image | |
run: | | |
docker buildx build --platform linux/amd64,linux/arm64 \ | |
--cache-from=type=registry,ref=${{ env.ACR_ADDRESS }}/${{ env.CACHE_REPOSITORY }} \ | |
--cache-to=type=registry,ref=${{ env.ACR_ADDRESS }}/${{ env.CACHE_REPOSITORY }},mode=max \ | |
--target aio \ | |
-t ${{ env.ACR_ADDRESS }}/aio:${{ steps.gitversion.outputs.semVer }} \ | |
-t ${{ env.ACR_ADDRESS }}/aio:${{ env.TAG }} \ | |
--push \ | |
. | |
env: | |
ACR_ADDRESS: ${{ secrets.ACR_ADDRESS }} | |
CACHE_REPOSITORY: build-cache | |
- name: Build API Docker Image | |
run: | | |
docker buildx build --platform linux/amd64,linux/arm64 \ | |
--cache-from=type=registry,ref=${{ env.ACR_ADDRESS }}/${{ env.CACHE_REPOSITORY }} \ | |
--target api \ | |
-t ${{ env.ACR_ADDRESS }}/api:${{ steps.gitversion.outputs.semVer }} \ | |
-t ${{ env.ACR_ADDRESS }}/api:${{ env.TAG }} \ | |
--push \ | |
. | |
env: | |
ACR_ADDRESS: ${{ secrets.ACR_ADDRESS }} | |
CACHE_REPOSITORY: build-cache | |
- name: Build Worker Docker Image | |
run: | | |
docker buildx build --platform linux/amd64,linux/arm64 \ | |
--cache-from=type=registry,ref=${{ env.ACR_ADDRESS }}/${{ env.CACHE_REPOSITORY }} \ | |
--target worker \ | |
-t ${{ env.ACR_ADDRESS }}/worker:${{ steps.gitversion.outputs.semVer }} \ | |
-t ${{ env.ACR_ADDRESS }}/worker:${{ env.TAG }} \ | |
--push \ | |
. | |
env: | |
ACR_ADDRESS: ${{ secrets.ACR_ADDRESS }} | |
CACHE_REPOSITORY: build-cache |