name: Deployment on DockerHub and Hugging Face # Trigger the workflow on push and pull request events to the 'main' or 'master' branch on: push: branches: - "master" - "main" - "test-deployment" pull_request: branches: - "master" - "main" jobs: build-and-deploy: # Run the job on the latest Ubuntu runner runs-on: ubuntu-latest steps: # Step 1: Check out the latest code from the repository - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 lfs: true # Step 2: Set up Git LFS - name: Set up Git LFS run: | git lfs install git lfs pull # Step 3: Remove binary files from git history - name: Remove binary files from git history run: | git filter-branch --force --index-filter \ "git rm --cached --ignore-unmatch DiverseSelector/test/test2/BBB_SECFP6_1024.xlsx DiverseSelector/test/test2/BBB_SECFP6_2048.xlsx" \ --prune-empty --tag-name-filter cat -- --all # Step 4: Set up Python environment with version 3.11 - name: Set up Python uses: actions/setup-python@v5 with: python-version: 3.11 # Step 5: Install the required dependencies - name: Install dependencies run: | pip install -r requirements.txt # Step 6: Build the Docker image to Docker Hub - name: Build Docker image run: | docker build . -t jackyzzz076/selector-deployment:latest # Step 7: Push the Docker image to Docker Hub - name: Push Docker image run: | docker login -u jackyzzz076 -p ${{ secrets.DOCKERHUB_TOKEN }} docker push jackyzzz076/selector-deployment:latest # Step 8: Replace the README.md file for Hugging Face - name: Replace README for Hugging Face run: | mv README_hf.md README.md git config --global user.name "github-actions[bot]" git config --global user.email "qcdevs@gmail.com" git add README.md git commit -m "Replace README.md with README_hf.md for Hugging Face" # Step 9: Push the app to Hugging Face - name: Push to Hugging Face env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | git push https://JackyZzZzZ:$HF_TOKEN@huggingface.co/spaces/JackyZzZzZ/selector HEAD:main --force