79 lines
2.1 KiB
YAML
79 lines
2.1 KiB
YAML
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 |