https://cloud.tencent.com/developer/article/1967214
1.按照node.js方法,建一个仓库,生成node.js文件
Dockerfile文件
server.js文件
2.workflow工作流文件,要在settings设置dockerhub的用户名和token口令,远程主机的用户名密码端口
代码语言:txt复制name: ci
on:
push:
branches:
- 'main'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
push: true
tags: yaodo/nodejstest:latest
-
name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: 146.56.112.29
username: ${{ secrets.REMOTE_USERNAME }}
password: ${{ secrets.REMOTE_PASSWORD }}
port: ${{ secrets.REMOTE_PORT }}
script: |
docker rm -f nodejstest
docker pull yaodo/nodejstest
docker run -p 49160:8080 -d yaodo/nodejstest