Skip to content

Publish Model

Publish Model #15

name: Publish Model
run-name: Publish Model
on:
push:
branches:
- main
jobs:
publish_model:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up DVC
uses: iterative/setup-dvc@v1
- name: Pull model
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
dvc pull live/model/model.pkl live/model/model.onnx
- name: Push on Hugging Face
env:
HF_USERNAME: ${{ vars.HF_USERNAME }}
HF_MODEL: phishing-url-detection
HF_TOKEN: ${{ secrets.HF_TOKEN }}
BRANCH: ${{ github.ref_name }}
CURRENT_REPO: ${{ github.workspace }}
HP_MODEL_REPO: /home/runner/work/hf_model_hub
run: |
mkdir -p $HP_MODEL_REPO && cd $HP_MODEL_REPO
git clone https://$HF_USERNAME:$HF_TOKEN@huggingface.co/$HF_USERNAME/$HF_MODEL
cd $HF_MODEL
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
if git ls-remote --heads origin $BRANCH | grep -q $BRANCH; then
git checkout $BRANCH
else
git checkout -b $BRANCH
fi
cp -r $CURRENT_REPO/live/model/* .
git add --all
git diff-index --quiet HEAD || git commit -m "push model from github actions"
git push origin $BRANCH