github-test / .github /workflows /huggingface-test.yaml
stepsecurity-app[bot]
stepsecurity-app[bot]
pre-commit-ci[bot]
[StepSecurity] Apply security best practices (#301)
7de4c72 unverified
Raw History Blame Contribute Delete
1.8 kB
name: Test on Hugging Face hub
on:
pull_request:
branches: ["*"]
permissions:
contents: write
pull-requests: write
jobs:
build-docker-image:
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Build Docker image
env:
IMAGE_NAME: ${{ github.repository_owner }}/github-test
run: |
docker build -t $IMAGE_NAME .
sync-to-hub:
needs: build-docker-image
runs-on: ubuntu-latest
environment: HF_TOKEN
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
lfs: true
- name: Configure Git
run: |
git config --global user.email "action@github.com"
git config --global user.name "github-actions"
- name: Push to Hugging Face Hub
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
HF_USERNAME: ${{ github.repository_owner }}
HF_SPACE: ${{ github.repository_owner }}/github-test
HF_BRANCH: main
PR_BRANCH: ${{ github.head_ref }}
run: |
git remote set-url origin https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_SPACE
git push origin $PR_BRANCH:$HF_BRANCH --force