Update README.md #17
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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | ||
name: Node.js CI | ||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
jobs: | ||
# test: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
# - name: Use Node.js 20.5.1 | ||
# uses: actions/setup-node@v4 | ||
# with: | ||
# node-version: 20.5.1 | ||
# - name: Install package | ||
# run: npm install | ||
# working-directory: ./was | ||
# - name: npm build | ||
# run: npm run build --if-present | ||
# working-directory: ./was | ||
# - name: npm test | ||
# run: npm test | ||
# working-directory: ./was | ||
build_docker: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
context: ./was | ||
push: true | ||
tags: ghcr.io/yunuo46/was_test:latest | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GHCR_TOKEN }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./was | ||
push: true | ||
tags: ghcr.io/yunuo46/was_test:latest | ||
deploy_docker: | ||
needs: build_docker | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: SSH Version Check | ||
run: ssh -V | ||
- name: Deploy to Server via SSH | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SERVER_HOST }} | ||
username: ${{ secrets.SERVER_USERNAME }} | ||
password: ${{ secrets.SERVER_PASSWORD }} | ||
port: 22 | ||
script: | | ||
ssh -i ~/.ssh/id_rsa [email protected] << 'EOF' | ||
echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
docker pull ghcr.io/yunuo46/was_test:latest | ||
docker stop was_test || true | ||
docker rm was_test || true | ||
docker run -d --name was_test -p 3000:3000 ghcr.io/yunuo46/was_test:latest |