kohlin's picture
Update ci.yml
4f2098d
raw
history blame
2.65 kB
name: CI/CD Pipeline
on:
push:
branches:
- "feature/**"
- develop
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.9
- name: Run Tests
run: python -m unittest discover -s tests || echo "No tests found"
merge-to-develop:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/feature/')
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Merge Feature Branch into Develop
run: |
git fetch origin
git checkout develop
git merge --no-ff "${{ github.ref }}"
# Update remote URL to use GITHUB_TOKEN for pushing:
git remote set-url origin https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }}.git
git push origin develop
merge-to-main:
needs: merge-to-develop
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop'
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Merge Develop Branch into Main
run: |
git fetch origin
git checkout main
git merge --no-ff origin/develop
# Update remote URL to use GITHUB_TOKEN for pushing:
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git push origin main
docker-build:
needs: merge-to-main
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: kohlin/nlp-project:latest