diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..8b46211 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,26 @@ +name: CI + +on: + # push: + # branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + # - name: Test + # run: dotnet test --no-build --verbosity normal + diff --git a/.gitea/workflows/master.yml b/.gitea/workflows/master.yml new file mode 100644 index 0000000..dce2a01 --- /dev/null +++ b/.gitea/workflows/master.yml @@ -0,0 +1,98 @@ +name: Master Build + +on: + push: + branches: [ "master" ] + +jobs: + build_amd64: + name: Build and Push Docker Image (amd64) + runs-on: self-hosted-ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: https://github.com/docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: https://github.com/docker/setup-buildx-action@v1 + + - name: Available platforms + run: echo ${{ steps.buildx.outputs.platforms }} + + - name: Build Docker image and push + id: docker_build + uses: https://github.com/docker/build-push-action@v2 + with: + context: ./ + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/kasbot:latest + platforms: linux/amd64 + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} + + build_arm64: + name: Build and Push Docker Image (arm64) + runs-on: self-hosted-ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + + - name: Set up QEMU + uses: https://github.com/docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: https://github.com/docker/setup-buildx-action@v1 + + - name: Available platforms + run: echo ${{ steps.buildx.outputs.platforms }} + + - name: Build Docker image and push + id: docker_build + uses: https://github.com/docker/build-push-action@v2 + with: + context: ./ + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/kasbot:latest + platforms: linux/arm64 + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} + + + deploy: + name: Update running container + runs-on: self-hosted-ubuntu-latest + needs: build_arm64 + + steps: + - name: Recreate container + uses: https://github.com/appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + port: ${{ secrets.PORT }} + script: | + cd docker/kasbot + docker compose down + docker compose rm + docker compose pull + docker compose up -d