From b749c0bf833af94da8f82c20ac2388988a210938 Mon Sep 17 00:00:00 2001 From: xun Date: Wed, 17 Jul 2024 21:12:55 +0800 Subject: [PATCH] Update github action --- .../workflows/{deploy.yml => dev-deploy.yml} | 21 ++++++++++++++++++- docker/Dockerfile | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) rename .github/workflows/{deploy.yml => dev-deploy.yml} (74%) diff --git a/.github/workflows/deploy.yml b/.github/workflows/dev-deploy.yml similarity index 74% rename from .github/workflows/deploy.yml rename to .github/workflows/dev-deploy.yml index 32690f4..4e5b818 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/dev-deploy.yml @@ -31,6 +31,7 @@ jobs: docker buildx build --platform linux/amd64 -t sast/sast-link -f docker/Dockerfile --output type=docker,dest=image.tar . - name: Deploy to Server + id: deploy uses: easingthemes/ssh-deploy@main with: SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} @@ -40,9 +41,27 @@ jobs: REMOTE_USER: ${{ secrets.REMOTE_USER }} TARGET: /tmp/image.tar SCRIPT_AFTER: | - docker load -i tmp/image.tar + ### Notice: run for develop ### + # Stop and remove existing container if it exists + if [ "$(docker ps -aq -f name=sastlink)" ]; then + docker stop sastlink + docker rm sastlink + fi + # Remove existing image if it exists + if [ "$(docker images -q sast/sast-link)" ]; then + docker rmi sast/sast-link + fi + # Load the new image and run it + docker load -i ~/image.tar docker run -d --name sastlink -p 8080:8080 sast/sast-link + - name: Check Deployment Status + run: | + if [ "${{ steps.deploy.outcome }}" != "success" ]; then + echo "Deployment failed" + exit 1 + fi + - name: Send Success Message if: ${{ success() }} run: | diff --git a/docker/Dockerfile b/docker/Dockerfile index 6090d8b..a10bc30 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,7 +5,7 @@ FROM golang:1.22 AS builder ADD src /sastlink ENV GO111MODULE=on -ENV GOPROXY=https://goproxy.cn +# ENV GOPROXY=https://goproxy.cn RUN cd /sastlink && CGO_ENABLED=0 go build # ----------------------------------------------------------------