From e66e8aa4d4f5b01cf9fbe5cb2b2c0a6e169b475b Mon Sep 17 00:00:00 2001 From: sasse Date: Mon, 18 Nov 2024 08:50:26 +0100 Subject: [PATCH] add ci --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2af3c7e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: Continuous Integration + +on: + pull_request: { branches: [ "main" ] } + push: + branches: [ "main" ] + tags: [ "*" ] +env: + GIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} +jobs: + build: + name: "Build Image" + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - id: generate-image-tag + name: Generate Image Tag + env: + ref_name: "${{ github.ref_name }}" + head_ref: "${{ github.head_ref }}" + run: | + head_ref="${head_ref/\//-}" + ref_name="${head_ref:-${ref_name/main/latest}}" + echo "::set-output name=imageTag::${ref_name#v}" + - name: Login to Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and Push Backend + uses: docker/build-push-action@v2 + with: + context: ./api + push: true + tags: | + ghcr.io/${{ github.repository }}/backend:${{ steps.generate-image-tag.outputs.imageTag }} + ghcr.io/${{ github.repository }}/backend:${{ github.event.pull_request.head.sha || github.sha }} + build-args: | + COMMIT_SHA=${{ github.sha }} + HF_TOKEN=${{ secrets.HF_TOKEN }} \ No newline at end of file