Skip to content

Commit

Permalink
Merge pull request #89 from NJUPT-SAST/deploy
Browse files Browse the repository at this point in the history
Update github action
  • Loading branch information
Xunop authored Jul 17, 2024
2 parents ebd0a7e + b749c0b commit e4984c4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

# ----------------------------------------------------------------
Expand Down

0 comments on commit e4984c4

Please sign in to comment.