Skip to content

Commit

Permalink
ci: migrate to reusable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
winstxnhdw committed Sep 20, 2023
1 parent d92f00f commit c186988
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 144 deletions.
43 changes: 5 additions & 38 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,15 @@ on:

jobs:
test:
uses: winstxnhdw/CapGen/.github/workflows/main.yml@main
uses: winstxnhdw/actions/.github/workflows/python.yml@main

build:
runs-on: ubuntu-latest
uses: winstxnhdw/actions/.github/workflows/docker-push.yml@main
secrets: inherit
permissions:
packages: write
env:
REGISTRY: ghcr.io

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
uses: docker/[email protected]
id: meta
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
file: Dockerfile.build
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

restart:
needs: [test, build]
runs-on: ubuntu-latest
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}

steps:
- name: Factory restart API
run: |
curl -X POST https://huggingface.co/api/spaces/$GITHUB_REPOSITORY/restart?factory=true \
-H "Authorization: Bearer $HF_TOKEN"
uses: winstxnhdw/actions/.github/workflows/spaces-restart.yml@main
secrets: inherit
18 changes: 5 additions & 13 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@ name: Dependabot

on: pull_request

permissions:
contents: write

jobs:
test:
uses: winstxnhdw/CapGen/.github/workflows/main.yml@main
uses: winstxnhdw/actions/.github/workflows/python.yml@main

auto-merge:
needs: test
if: ${{ github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest

steps:
- name: Auto-merge Dependabot PRs
run: gh pr merge --auto --rebase $PR_URL
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: winstxnhdw/actions/.github/workflows/dependabot-public.yml@main
secrets: inherit
permissions:
contents: write
24 changes: 2 additions & 22 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,5 @@ on:

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set Git config
run: |
git config --global user.email github-actions[bot]@users.noreply.github.com
git config --global user.name github-actions[bot]
- name: Push to Hugging Face Spaces
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
REPOSITORY_NAME: ${{ github.event.repository.name }}
run: |
git clone https://$GITHUB_REPOSITORY_OWNER:[email protected]/spaces/$GITHUB_REPOSITORY_OWNER/$REPOSITORY_NAME
pushd $REPOSITORY_NAME
mv ../Dockerfile .
git add Dockerfile
git commit --amend -m "$(git show -s --format=%s)"
git push --force-with-lease
uses: winstxnhdw/actions/.github/workflows/spaces-deploy.yml@main
secrets: inherit
29 changes: 2 additions & 27 deletions .github/workflows/formatter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Format
on:
push:
paths:
- '**.py'
- .github/workflows/formatter.yml
- '**.py'
- tsconfig.json
- pyproject.toml

Expand All @@ -13,29 +13,4 @@ permissions:

jobs:
format:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Sort imports
uses: isort/isort-action@master
with:
configuration: --atomic

- name: Set Git config
run: |
git config user.email github-actions[bot]@users.noreply.github.com
git config user.name github-actions[bot]
- name: Commit changes
run: |
git add .
git commit -m "style: format scripts" || true
git push || true
uses: winstxnhdw/actions/.github/workflows/format-python.yml@main
32 changes: 0 additions & 32 deletions .github/workflows/main.yml

This file was deleted.

13 changes: 1 addition & 12 deletions .github/workflows/warmer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,4 @@ on:

jobs:
warm:
runs-on: ubuntu-latest
env:
REPOSITORY_NAME: ${{ github.event.repository.name }}

steps:
- name: cURL Swagger
run: |
[ ! "$(curl https://$GITHUB_REPOSITORY_OWNER-$REPOSITORY_NAME.hf.space/api/docs)" = "{\"detail\":\"Not Found\"}" ]
- name: cURL the API
run: |
[ "$(curl https://$GITHUB_REPOSITORY_OWNER-$REPOSITORY_NAME.hf.space/api/v1/)" = "Welcome to v1 of the API!" ]
uses: winstxnhdw/actions/.github/workflows/spaces-warmer.yml@main

0 comments on commit c186988

Please sign in to comment.