From 74904a33fd84e3f9c3e54ed5e63f9d3f7af58ed9 Mon Sep 17 00:00:00 2001 From: clive Date: Sun, 19 May 2024 13:39:37 +1000 Subject: [PATCH] Commit: Add action yaml. --- .gitea/workflows/default.yml | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .gitea/workflows/default.yml diff --git a/.gitea/workflows/default.yml b/.gitea/workflows/default.yml new file mode 100644 index 0000000..c5ff3c6 --- /dev/null +++ b/.gitea/workflows/default.yml @@ -0,0 +1,46 @@ +name: Gitea CI/CD + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Login to Docker registry + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + registry: https://registry.rokoh.com + + - name: Build Docker image + run: docker build . -t rokoh:latest -f plushealthtech/Dockerfile + + - name: Tag Docker image + run: docker tag rokoh:latest registry.rokoh.com/plushealthtech:latest + + - name: Push Docker image to registry + run: docker push registry.rokoh.com/plushealthtech:latest + + - name: SSH Deploy + uses: appleboy/ssh-action@v1.0.3 + with: + host: 10.1.1.90 + username: ${{ secrets.SERVER_USERNAME }} + password: ${{ secrets.SERVER_PASSWORD }} + script: | + if docker ps -a --format '{{.Names}}' | grep -q rokoh; then + docker stop plushealthtech || true + docker rm plushealthtech || true + docker image rm plushealthtech:latest + fi + docker login registry.rokoh.com -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} && docker image pull registry.rokoh.com/plushealthtech:latest + docker run -d -p 2000:80 --restart=always --name rokoh registry.rokoh.com/plushealthtech + docker image prune -f + + - name: Prune Docker resources + run: docker system prune -af --volumes \ No newline at end of file