From a4a651229ce2f4684c23775c3ccdb292e0b40de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sat, 12 Aug 2023 11:52:02 +0200 Subject: [PATCH] Added gitea-actions workflow --- .gitea/workflows/build_and_deploy.yml | 43 +++++++++++++++++++++++++++ scnserver/Makefile | 6 ++-- 2 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 .gitea/workflows/build_and_deploy.yml diff --git a/.gitea/workflows/build_and_deploy.yml b/.gitea/workflows/build_and_deploy.yml new file mode 100644 index 0000000..d761a52 --- /dev/null +++ b/.gitea/workflows/build_and_deploy.yml @@ -0,0 +1,43 @@ + +# https://docs.gitea.com/next/usage/actions/quickstart +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions +# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context + +name: Build Docker and Deploy +run-name: Build & Deploy ${{ gitea.ref }} on ${{ gitea.actor }} + +on: + push: + branches: ['master'] + + + +jobs: + build_job: + name: Build Docker Container + runs-on: bfb-cicd-latest + steps: + - run: echo -n "${{ secrets.DOCKER_REG_PASS }}" | docker login registry.blackforestbytes.com -u docker --password-stdin + - name: Check out code + uses: actions/checkout@v3 + - run: cd "${{ gitea.workspace }}/scnserver" && make clean + - run: cd "${{ gitea.workspace }}/scnserver" && make docker + - run: cd "${{ gitea.workspace }}/scnserver" && make push-docker + + deploy_job: + name: Deploy to Server + needs: [build_job] + runs-on: ubuntu-latest + steps: + - name: Execute deploy on remote (via ssh) + uses: appleboy/ssh-action@v1.0.0 + with: + host: simplecloudnotifier.de + username: bfb-deploy-bot + port: 4477 + key: "${{ secrets.SSH_KEY_BFBDEPLOYBOT }}" + script: cd /var/docker/deploy-scripts/simplecloudnotifier && ./deploy.sh master "${{ gitea.sha }}" || exit 1 + + + + diff --git a/scnserver/Makefile b/scnserver/Makefile index 977d187..a3b1fc2 100644 --- a/scnserver/Makefile +++ b/scnserver/Makefile @@ -67,7 +67,7 @@ inspect-docker: docker $(DOCKER_NAME):latest \ bash -push-docker: docker +push-docker: docker image push "$(DOCKER_REPO)/$(DOCKER_NAME):$(HASH)" docker image push "$(DOCKER_REPO)/$(DOCKER_NAME):$(NAMESPACE)-latest" docker image push "$(DOCKER_REPO)/$(DOCKER_NAME):latest" @@ -76,8 +76,8 @@ clean: rm -rf _build/* rm -rf .run-data/* git clean -fdx - go clean - go clean -testcache + which go && go clean || true + which go && go clean -testcache || true fmt: go fmt ./...