From 5b846c1006ab192c1fbd29092d37faa3ef193246 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Fri, 13 Oct 2023 01:07:36 +0200 Subject: [PATCH] ci: added CI/CD workflow --- .gitea/workflows/deploy.yml | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..5553ab2 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,58 @@ +name: Build and Deploy +on: + push: + branches: + - "master" + paths-ignore: + - "docs" + - ".sqlx" + - "**.md" + +jobs: + build-docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Cache Docker layers + uses: https://github.com/actions/cache@v3 + with: + path: | + /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-api-${{ gitea.sha }} + restore-keys: | + ${{ runner.os }}-buildx-api- + + - name: Login to Container Registry + uses: docker/login-action@v3 + with: + registry: git.nerdcult.net/nerdcult + username: nerdcultbot + password: ${{ secrets.NerdcultBotToken }} + + - name: Build and Push + uses: docker/build-push-action@v5 + env: + ACTIONS_RUNTIME_TOKEN: '' + with: + context: . + push: true + tags: git.nerdcult.net/nerdcult/nerdcult_api:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + + - name: Rotate the cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + - name: Deploy + env: + TOWER_TOKEN: ${{ secrets.WatchtowerToken}} + TOWER_URI: ${{ secrets.WatchtowerURI}} + run: | + curl -H "Authorization: Bearer $TOWER_TOKEN" $TOWER_URI