soutrik commited on
Commit
9e1c398
β€’
1 Parent(s): 4b9a979

main pipeline

Browse files
.github/workflows/hf_deploy.yaml CHANGED
@@ -3,7 +3,7 @@ name: Sync to Hugging Face Hub for Gradio App MNIST Classifier # this is not wo
3
  on:
4
  push:
5
  branches:
6
- - main
7
 
8
  jobs:
9
  sync-to-hub:
 
3
  on:
4
  push:
5
  branches:
6
+ - master
7
 
8
  jobs:
9
  sync-to-hub:
.github/workflows/main_cd.yml CHANGED
@@ -1,9 +1,10 @@
1
- name: Deploy PyTorch Training with all advanced features like self-hosted EC2 runner, Docker Buildx, Amazon ECR, Hugging Face Spaces
2
 
3
  on:
4
  push:
5
  branches:
6
  - master
 
7
  workflow_dispatch:
8
 
9
  jobs:
@@ -36,6 +37,9 @@ jobs:
36
  name: Deploy PyTorch Training Pipeline
37
  needs: start-runner
38
  runs-on: ${{ needs.start-runner.outputs.label }}
 
 
 
39
  steps:
40
  - name: Checkout repository
41
  uses: actions/checkout@v4
@@ -62,14 +66,6 @@ jobs:
62
  id: login-ecr
63
  uses: aws-actions/amazon-ecr-login@v2
64
 
65
- - name: Create .env file
66
- run: |
67
- echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" >> .env
68
- echo "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> .env
69
- echo "AWS_REGION=${{ secrets.AWS_REGION }}" >> .env
70
- echo "::add-mask::${{ secrets.AWS_ACCESS_KEY_ID }}"
71
- echo "::add-mask::${{ secrets.AWS_SECRET_ACCESS_KEY }}"
72
-
73
  - name: Run Docker Compose for all services
74
  run: |
75
  docker-compose build --no-cache
@@ -99,14 +95,71 @@ jobs:
99
 
100
  - name: Clean up environment
101
  run: |
102
- rm -f .env
103
  docker system prune -af --volumes
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  stop-runner:
106
  name: Stop self-hosted EC2 runner
107
  needs:
108
  - start-runner
109
  - deploy
 
110
  runs-on: ubuntu-latest
111
  if: ${{ always() }}
112
  steps:
 
1
+ name: Deploy PyTorch Training with Hugging Face Sync
2
 
3
  on:
4
  push:
5
  branches:
6
  - master
7
+ - main
8
  workflow_dispatch:
9
 
10
  jobs:
 
37
  name: Deploy PyTorch Training Pipeline
38
  needs: start-runner
39
  runs-on: ${{ needs.start-runner.outputs.label }}
40
+ outputs:
41
+ ecr-registry: ${{ steps.login-ecr.outputs.registry }}
42
+ image-tag: ${{ github.sha }}
43
  steps:
44
  - name: Checkout repository
45
  uses: actions/checkout@v4
 
66
  id: login-ecr
67
  uses: aws-actions/amazon-ecr-login@v2
68
 
 
 
 
 
 
 
 
 
69
  - name: Run Docker Compose for all services
70
  run: |
71
  docker-compose build --no-cache
 
95
 
96
  - name: Clean up environment
97
  run: |
 
98
  docker system prune -af --volumes
99
 
100
+ sync-to-hub:
101
+ name: Sync to Hugging Face Hub
102
+ needs: deploy
103
+ runs-on: ubuntu-latest
104
+ steps:
105
+ - uses: actions/checkout@v4
106
+ with:
107
+ fetch-depth: 0
108
+ lfs: true
109
+
110
+ - name: Install Git LFS
111
+ run: |
112
+ curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
113
+ sudo apt-get install git-lfs
114
+ git lfs install
115
+
116
+ - name: Configure Git identity
117
+ run: |
118
+ git config --global user.name "soutrik"
119
+ git config --global user.email "soutrik.chowdhury@ab-inbev.com"
120
+
121
+ - name: Add remote
122
+ run: |
123
+ git remote add space https://$USER:$HF_TOKEN@huggingface.co/spaces/$USER/$SPACE
124
+ env:
125
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
126
+ USER: soutrik
127
+ SPACE: gradio_demo_MNIST_Classifier
128
+
129
+ - name: Ensure LFS objects are present
130
+ run: git lfs checkout
131
+
132
+ - name: Add README.md
133
+ run: |
134
+ cat <<EOF > README.md
135
+ ---
136
+ title: My Gradio App MNIST Classifier
137
+ emoji: πŸš€
138
+ colorFrom: blue
139
+ colorTo: green
140
+ sdk: gradio
141
+ sdk_version: "5.7.1"
142
+ app_file: app.py
143
+ pinned: false
144
+ ---
145
+ EOF
146
+ git add README.md
147
+ git commit -m "Add README.md" || echo "Skip commit if no changes"
148
+
149
+ - name: Push to hub
150
+ run: |
151
+ git push --force https://$USER:$HF_TOKEN@huggingface.co/spaces/$USER/$SPACE main
152
+ env:
153
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
154
+ USER: soutrik
155
+ SPACE: gradio_demo_MNIST_Classifier
156
+
157
  stop-runner:
158
  name: Stop self-hosted EC2 runner
159
  needs:
160
  - start-runner
161
  - deploy
162
+ - sync-to-hub
163
  runs-on: ubuntu-latest
164
  if: ${{ always() }}
165
  steps: