From a2be993c0b3d23fa49fd8818606eae8c6220df74 Mon Sep 17 00:00:00 2001 From: Ivan Usov Date: Mon, 31 Mar 2025 14:02:30 +0200 Subject: [PATCH] Add gitea deploy workflow --- .gitea/workflows/deploy.yaml | 79 ++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .gitea/workflows/deploy.yaml diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..582cbae --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,79 @@ +name: CI/CD Pipeline + +on: + push: + branches: + - main + tags: + - '*' + +jobs: + build: + runs-on: pyzebra + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Conda + run: | + source /opt/miniconda3/etc/profile.d/conda.sh + conda config --add channels conda-forge + conda config --set solver libmamba + + - name: Determine build path + id: build_path + run: | + if [[ "${{ github.ref }}" == refs/tags/* ]]; then + echo "BUILD_PATH=${{ runner.temp }}/build-prod" >> $GITHUB_ENV + else + echo "BUILD_PATH=${{ runner.temp }}/build-test" >> $GITHUB_ENV + fi + + - name: Build Conda package + run: | + conda build --no-anaconda-upload --output-folder $BUILD_PATH ./conda-recipe + + deploy-test: + runs-on: pyzebra + needs: build + if: github.ref == 'refs/heads/main' + steps: + - name: Deploy to testing + run: | + source /opt/miniconda3/etc/profile.d/conda.sh + conda activate test + conda install --channel $BUILD_PATH --force-reinstall pyzebra -y + sudo systemctl restart pyzebra-test.service + + deploy-prod: + runs-on: pyzebra + needs: build + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Deploy to production + run: | + source /opt/miniconda3/etc/profile.d/conda.sh + conda activate prod + conda install --channel $BUILD_PATH pyzebra -y + sudo systemctl restart pyzebra-prod.service + + publish: + runs-on: pyzebra + needs: deploy-prod + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Publish to Anaconda + run: | + source /opt/miniconda3/etc/profile.d/conda.sh + conda activate base + anaconda --token ${{ secrets.ANACONDA_TOKEN }} upload $(conda build --output-folder $BUILD_PATH ./conda-recipe --output) + + cleanup: + runs-on: pyzebra + needs: [build, deploy-test, deploy-prod, publish] + if: always() + steps: + - name: Cleanup + run: | + rm -rf $BUILD_PATH + conda build purge-all \ No newline at end of file