From 4cdcb1f47a3e56a34a5e193c10be1c2f481c5237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Du=CC=88rrwald?= Date: Wed, 12 Jun 2024 21:16:39 +0200 Subject: [PATCH] chore: Add CD to CI --- .gitea/workflows/publish.yml | 39 ++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml index 988e3d5..43f51a8 100644 --- a/.gitea/workflows/publish.yml +++ b/.gitea/workflows/publish.yml @@ -13,21 +13,30 @@ jobs: - name: Check out repository uses: actions/checkout@v4 - - name: Set up Docker Buildx 🚀 - uses: docker/setup-buildx-action@v3 + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v35 + with: + since_last_remote_commit: true + separator: "," - - name: Login to Docker Hub 🚢 - uses: docker/login-action@v3 + - name: Copy repository contents + uses: appleboy/scp-action@0.1.7 with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Build and push 🏗️ - uses: docker/build-push-action@v2 + host: ${{ secrets.HOST }} + port: ${{ secrets.PORT }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + passphrase: ${{ secrets.PASSPHRASE }} + source: ${{ steps.changed-files.outputs.all_changed_files }} + target: ${{ secrets.REMOTE_PATH }} + + - name: Restart remote application + uses: appleboy/ssh-action@1.0.3 with: - context: . - file: ./Dockerfile - push: false - # tags: | - # ${{ secrets.DOCKER_HUB_USERNAME}}/{docker_repository}:${{ github.sha }} - # ${{ secrets.DOCKER_HUB_USERNAME}}/{docker_repository}:latest \ No newline at end of file + host: ${{ inputs.host }} + port: ${{ inputs.port }} + username: ${{ inputs.username }} + key: ${{ secrets.KEY }} + passphrase: ${{ secrets.PASSPHRASE }} + script: cd ${{ secrets.remote-path }} && docker build . && docker run -p 3000:3000