feat: support read site version from release tag #50
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: deploy-demo-site | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ "main" ] | |
jobs: | |
build-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20.x" | |
- name: Set up Golang | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.20" | |
- name: Install npm dependencies | |
run: npm ci | |
working-directory: web/ | |
- name: Run npm build | |
run: export NODE_ENV=prod && npm run build:demo | |
working-directory: web/ | |
- name: Check build static | |
run: ls dist/ -la | |
working-directory: web/ | |
- name: Get Release version | |
id: get_version | |
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT | |
- name: Update Local Version File | |
run: echo ${{ steps.get_version.outputs.VERSION }} > .release_version | |
- name: Install Go modules | |
run: go mod tidy | |
- name: Build Go | |
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o Message-Nest | |
- name: Copy files to server | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
port: ${{ secrets.SERVER_PORT }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
password: ${{ secrets.SERVER_PASSWD }} | |
source: "Message-Nest" | |
target: ${{ secrets.REMOTE_DEMO_TARGET }} | |
- name: SSH into server and restart service | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
port: ${{ secrets.SERVER_PORT }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
password: ${{ secrets.SERVER_PASSWD }} | |
script: | | |
${{ secrets.REMOTE_DEMO_SCRIPT }} |