From dba48e35995360f7dadb33b95ae981a85a187771 Mon Sep 17 00:00:00 2001 From: LordMathis Date: Wed, 31 Jan 2024 13:38:37 +0100 Subject: [PATCH] Combine workflows --- .gitea/workflows/release.yaml | 36 +++++++++++++++++++++++++++++++++-- .gitea/workflows/tag.yaml | 30 ----------------------------- 2 files changed, 34 insertions(+), 32 deletions(-) delete mode 100644 .gitea/workflows/tag.yaml diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 3566621..67bd2eb 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -1,12 +1,44 @@ name: Build and push mlflow container on: push: - tags: - - '[0-9]+.[0-9]+.[0-9]+' + branches: + - main 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 latest git tag + id: tag + run: echo "tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT + - name: Get mlflow version + id: mlflow + run: echo "mlflow=$(cat requirements.txt | grep mlflow | cut -d'=' -f3)" >> $GITHUB_OUTPUT + - name: Create tag if it doesn't exist + id: create + run: | + if git tag -l "${{ steps.tag.outputs.tag }}"; 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 + 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:8583ed2b7d097609ff91cc914696324ee945ceb8639967759f4cebbfcb8e63a5 env: diff --git a/.gitea/workflows/tag.yaml b/.gitea/workflows/tag.yaml deleted file mode 100644 index 6469df8..0000000 --- a/.gitea/workflows/tag.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: Create mlflow tag -on: - push: - branches: - - main - -jobs: - build: - 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 latest git tag - id: tag - run: echo "tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT - - name: Get mlflow version - id: mlflow - run: echo "mlflow=$(cat requirements.txt | grep mlflow | cut -d'=' -f3)" >> $GITHUB_OUTPUT - - name: Create tag if it doesn't exist - run: | - if git tag -l "${{ steps.tag.outputs.tag }}"; then - echo "Tag already exists" - else - git tag ${{ steps.mlflow.outputs.mlflow }} - git push origin ${{ steps.mlflow.outputs.mlflow }} - fi