Replace gitlab with gitea workflow
All checks were successful
pyzebra CI/CD pipeline / prepare (push) Successful in 1s
pyzebra CI/CD pipeline / test-env (push) Successful in 1m41s
pyzebra CI/CD pipeline / prod-env (push) Has been skipped
pyzebra CI/CD pipeline / cleanup (push) Successful in 1s

This commit is contained in:
usov_i 2025-03-31 14:02:30 +02:00
parent c2d6f6b259
commit c0567ab6c6
2 changed files with 62 additions and 60 deletions

View File

@ -0,0 +1,62 @@
name: pyzebra CI/CD pipeline
on:
push:
branches:
- main
tags:
- '*'
jobs:
prepare:
runs-on: pyzebra
steps:
- name: Set up Conda
run: |
source /opt/miniconda3/etc/profile.d/conda.sh
conda config --add channels conda-forge
conda config --set solver libmamba
test-env:
runs-on: pyzebra
needs: prepare
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build and deploy to testing
env:
BUILD_DIR: ${{ runner.temp }}/conda_build
run: |
source /opt/miniconda3/etc/profile.d/conda.sh
conda build --no-anaconda-upload --output-folder $BUILD_DIR ./conda-recipe
conda remove --name test --all --keep-env -y
conda install --name test --channel $BUILD_DIR python=3.8 pyzebra -y
sudo systemctl restart pyzebra-test.service
prod-env:
runs-on: pyzebra
needs: prepare
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build, upload and deploy to production
run: |
source /opt/miniconda3/etc/profile.d/conda.sh
conda build --token ${{ secrets.ANACONDA_TOKEN }} ./conda-recipe
conda remove --name prod --all --keep-env -y
conda install --name prod --use-local python=3.8 pyzebra -y
sudo systemctl restart pyzebra-prod.service
cleanup:
runs-on: pyzebra
needs: [test-env, prod-env]
if: always()
steps:
- name: Cleanup
run: |
source /opt/miniconda3/etc/profile.d/conda.sh
conda build purge-all

View File

@ -1,60 +0,0 @@
stages:
- build
- deploy
- publish
- cleanup
workflow:
rules:
- if: $CI_COMMIT_TAG
variables:
BUILD_PATH: $CI_BUILDS_DIR/build-prod
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
BUILD_PATH: $CI_BUILDS_DIR/build-test
default:
before_script:
- source /opt/miniconda3/etc/profile.d/conda.sh
build-job:
stage: build
script:
- conda config --add channels conda-forge
- conda config --set solver libmamba
- conda build --no-anaconda-upload --output-folder $BUILD_PATH ./conda-recipe
deploy-test-job:
stage: deploy
environment: testing
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- conda activate test
- conda install --channel $BUILD_PATH --force-reinstall pyzebra -y
- sudo systemctl restart pyzebra-test.service
deploy-prod-job:
stage: deploy
environment: production
rules:
- if: $CI_COMMIT_TAG
script:
- conda activate prod
- conda install --channel $BUILD_PATH pyzebra -y
- sudo systemctl restart pyzebra-prod.service
publish-job:
stage: publish
rules:
- if: $CI_COMMIT_TAG
script:
- conda activate base
- anaconda --token $ANACONDA_TOKEN upload $(conda build --output-folder $BUILD_PATH ./conda-recipe --output)
cleanup-job:
stage: cleanup
script:
- rm -rf $BUILD_PATH
- conda build purge-all
when: always