Skip to content

Commit

Permalink
Merge pull request #88 from NJUPT-SAST/deploy
Browse files Browse the repository at this point in the history
Update deploy process
  • Loading branch information
Xunop authored Jul 17, 2024
2 parents 717c928 + a96a51f commit ebd0a7e
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
pull_request:
types:
- closed

jobs:
build:
if: github.event.pull_request.merged
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build Docker image
run: |
docker buildx build --platform linux/amd64 -t sast/sast-link -f docker/Dockerfile --output type=docker,dest=image.tar .
- name: Deploy to Server
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
ARGS: "-rlgoDzvc -i --delete"
SOURCE: "./image.tar"
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: /tmp/image.tar
SCRIPT_AFTER: |
docker load -i tmp/image.tar
docker run -d --name sastlink -p 8080:8080 sast/sast-link
- name: Send Success Message
if: ${{ success() }}
run: |
bash ./scripts/webhook.sh \
-u "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
-w ${{ secrets.WEBHOOK_URL }} \
-s sastlink -c "${{ github.event.pull_request.user.login }}" -f 'success' \
-m "https://github.com/${{ github.repository }}/commit/${{ github.sha }}"
- name: Send Fail Message
if: ${{ failure() }}
run: |
bash ./scripts/webhook.sh \
-u "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
-w ${{ secrets.WEBHOOK_URL }} \
-s sastlink -c "${{ github.event.pull_request.user.login }}" -f 'failure' \
-m "https://github.com/${{ github.repository }}/commit/${{ github.sha }}"
4 changes: 2 additions & 2 deletions .github/workflows/link.yml.1
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ on:
jobs:
build:
if: github.event.pull_request.merged
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.22'

- name: Build
run: go build -o sast-link-backend
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ----------------------------------------------------------------
# 1. Build the application
# ----------------------------------------------------------------
FROM golang:1.22 as builder
FROM golang:1.22 AS builder

ADD src /sastlink
ENV GO111MODULE=on
Expand Down

0 comments on commit ebd0a7e

Please sign in to comment.