diff --git a/.github/workflows/build-push-docker-image.yml b/.github/workflows/build-push-docker-image.yml index 4706da5..2ad2e44 100644 --- a/.github/workflows/build-push-docker-image.yml +++ b/.github/workflows/build-push-docker-image.yml @@ -1,4 +1,4 @@ -name: Create and publish a Docker image +name: Create, publish and deploy Docker image on: push: @@ -64,3 +64,33 @@ jobs: subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} subject-digest: ${{ steps.push.outputs.digest }} push-to-registry: true + deploy: + name: Deploy to Server + needs: build-push-deploy-image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: upload infrastructure files + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.SSH_SECONDARY_HOST }} + username: ${{ secrets.SSH_SECONDARY_USERNAME }} + password: ${{ secrets.SSH_SECONDARY_PASSWORD }} + port: ${{ secrets.SSH_SECONDARY_PORT }} + source: infrastructure/* + target: . + - name: execute remote ssh commands + uses: appleboy/ssh-action@master + env: + SECRET: ${{ secrets.ENV_FILE }} + COMMIT_SHA: ${{ github.sha }} + with: + host: ${{ secrets.SSH_SECONDARY_HOST }} + username: ${{ secrets.SSH_SECONDARY_USERNAME }} + password: ${{ secrets.SSH_SECONDARY_PASSWORD }} + port: ${{ secrets.SSH_SECONDARY_PORT }} + envs: SECRET,COMMIT_SHA + script: | + cd Spybot2 + echo "$SECRET" > .env + docker-compose -f docker-compose-deploy.yml up diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/manual-deploy-docker.yml similarity index 93% rename from .github/workflows/deploy-docker.yml rename to .github/workflows/manual-deploy-docker.yml index e2415ec..b47f26f 100644 --- a/.github/workflows/deploy-docker.yml +++ b/.github/workflows/manual-deploy-docker.yml @@ -1,12 +1,10 @@ name: Deploy to server via docker image on: - push: - branches: [ "master", "workflow_dispatch" ] workflow_dispatch: jobs: deploy: - name: Deploy to Server + name: Deploy to Server manually needs: build-push-deploy-image runs-on: ubuntu-latest steps: