From f710eac1840f06288fec4c0089e4218f5885edad Mon Sep 17 00:00:00 2001 From: LordMathis Date: Wed, 31 Jan 2024 16:27:52 +0100 Subject: [PATCH] Split workflows --- .gitea/workflows/release.yaml | 47 +++-------------------------------- .gitea/workflows/tag.yaml | 31 +++++++++++++++++++++++ 2 files changed, 34 insertions(+), 44 deletions(-) create mode 100644 .gitea/workflows/tag.yaml diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 8840d98..393eacd 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -1,52 +1,12 @@ name: Build and push mlflow container on: push: - branches: - - main + tags: + - '[0-9]+.[0-9]+.[0-9]+' jobs: - - tag: - name: Create mlflow tag - runs-on: ubuntu-latest - outputs: - tag_created: ${{ steps.create.outputs.created }} - container: ghcr.io/catthehacker/ubuntu:act-latest@sha256:8583ed2b7d097609ff91cc914696324ee945ceb8639967759f4cebbfcb8e63a5 - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Fetch tags - run: git fetch --tags origin - - name: Get mlflow version - id: mlflow - run: | - mlflow=$(cat requirements.txt | grep mlflow | cut -d'=' -f3) - echo $mlflow - echo "mlflow=$mlflow" >> $GITHUB_OUTPUT - - name: Create tag if it doesn't exist - id: create - run: | - if git rev-parse "refs/tags/${{ steps.mlflow.outputs.mlflow }}" 2>/dev/null; then - echo "Tag already exists" - echo "created=false" >> $GITHUB_OUTPUT - else - git tag ${{ steps.mlflow.outputs.mlflow }} - git push origin ${{ steps.mlflow.outputs.mlflow }} - echo "created=true" >> $GITHUB_OUTPUT - fi - - debug: - needs: tag - runs-on: ubuntu-latest - steps: - - name: Debug output - run: | - echo "${{ toJson(needs.tag) }}" - build: name: Build and push mlflow container - needs: tag - if: ${{ needs.tag.outputs.tag_created == 'true' }} runs-on: ubuntu-latest container: ghcr.io/catthehacker/ubuntu:act-latest@sha256:07466dbbecd8690579d9bcbf8a1214240b91534cf03eed5f222e7fd80131f582 env: @@ -68,5 +28,4 @@ jobs: TODAY=$(date +'%Y-%m-%d') docker build -t ${REGISTRY}/${REPO_OWNER}/${IMAGE_NAME}:${VERSION}-${TODAY} -t ${REGISTRY}/${REPO_OWNER}/${IMAGE_NAME}:latest . docker push ${REGISTRY}/${REPO_OWNER}/${IMAGE_NAME}:${VERSION}-${TODAY} - docker push ${REGISTRY}/${REPO_OWNER}/${IMAGE_NAME}:latest - \ No newline at end of file + docker push ${REGISTRY}/${REPO_OWNER}/${IMAGE_NAME}:latest \ No newline at end of file diff --git a/.gitea/workflows/tag.yaml b/.gitea/workflows/tag.yaml new file mode 100644 index 0000000..00d3465 --- /dev/null +++ b/.gitea/workflows/tag.yaml @@ -0,0 +1,31 @@ +name: Tag mlflow release +on: + push: + branches: + - main + +jobs: + tag: + name: Create mlflow tag + runs-on: ubuntu-latest + container: ghcr.io/catthehacker/ubuntu:act-latest@sha256:8583ed2b7d097609ff91cc914696324ee945ceb8639967759f4cebbfcb8e63a5 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Fetch tags + run: git fetch --tags origin + - name: Get mlflow version + id: mlflow + run: | + mlflow=$(cat requirements.txt | grep mlflow | cut -d'=' -f3) + echo $mlflow + echo "mlflow=$mlflow" >> $GITHUB_OUTPUT + - name: Create tag if it doesn't exist + id: create + run: | + if git rev-parse "refs/tags/${{ steps.mlflow.outputs.mlflow }}" 2>/dev/null; then + echo "Tag already exists" + else + git tag ${{ steps.mlflow.outputs.mlflow }} + git push origin ${{ steps.mlflow.outputs.mlflow }} + fi