From 1a5ba83771b9f2490927038bc32d35b74809902c Mon Sep 17 00:00:00 2001 From: PROJECT ZERO <56379955+ProjectZeroDays@users.noreply.github.com> Date: Tue, 21 Jan 2025 06:21:56 -0600 Subject: [PATCH] Auto sync with Huggingface code space Add a new workflow to sync the repository with Huggingface code space. * **Workflow**: Add `sync_huggingface.yml` in `.github/workflows/` to trigger on push and pull_request events for the main branch. Include steps to checkout the repository, set up Python, install dependencies, and sync with Huggingface using the Huggingface API key from `codespace_user_secrets.json`. * **Kubernetes Deployment**: Update `infra/k8s_deployment.yaml` and `infra/k8s/deployment.yaml` to add `HUGGINGFACE_API_KEY` environment variable to the `env` section, referencing the Huggingface API key from a secret. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ProjectZeroDays/Project-Red-Sword?shareId=XXXX-XXXX-XXXX-XXXX). --- .github/workflows/sync_huggingface.yml | 33 ++++++++++++++++++++++++++ infra/k8s/deployment.yaml | 7 +++++- infra/k8s_deployment.yaml | 6 ++++- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/sync_huggingface.yml diff --git a/.github/workflows/sync_huggingface.yml b/.github/workflows/sync_huggingface.yml new file mode 100644 index 0000000..c7ef4d4 --- /dev/null +++ b/.github/workflows/sync_huggingface.yml @@ -0,0 +1,33 @@ +name: Sync with Huggingface + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + sync: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Sync with Huggingface + env: + HUGGINGFACE_API_KEY: ${{ secrets.HUGGINGFACE_API_KEY }} + run: | + python sync_huggingface.py diff --git a/infra/k8s/deployment.yaml b/infra/k8s/deployment.yaml index 3c90476..9cd7f6f 100644 --- a/infra/k8s/deployment.yaml +++ b/infra/k8s/deployment.yaml @@ -1,4 +1,3 @@ - apiVersion: apps/v1 kind: Deployment metadata: @@ -18,3 +17,9 @@ spec: image: cybersecurity/framework:latest ports: - containerPort: 5000 + env: + - name: HUGGINGFACE_API_KEY + valueFrom: + secretKeyRef: + name: huggingface-secret + key: api_key diff --git a/infra/k8s_deployment.yaml b/infra/k8s_deployment.yaml index 26aa1f8..75be2d1 100644 --- a/infra/k8s_deployment.yaml +++ b/infra/k8s_deployment.yaml @@ -1,4 +1,3 @@ - apiVersion: apps/v1 kind: Deployment metadata: @@ -24,3 +23,8 @@ spec: secretKeyRef: name: openai-secret key: api_key + - name: HUGGINGFACE_API_KEY + valueFrom: + secretKeyRef: + name: huggingface-secret + key: api_key