1 parent
ba117312ad
commit
87885a299b
33 files changed
+5581
-1
No files matched your search
@@ -0,0 +1,57 @@
|
||||
name: CI/CD
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: 设置 Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '20.2.0-buster'
|
||||
|
||||
- name: 设置淘宝依赖源
|
||||
run: npm config set registry https://registry.npmmirror.com
|
||||
|
||||
- name: 安装依赖
|
||||
run: npm i
|
||||
|
||||
- name: 构建项目
|
||||
run: npm run build
|
||||
|
||||
- name: 设置 Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: 登录到 Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: registry.cn-guangzhou.aliyuncs.com
|
||||
username: ${{ secrets.NROP_DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.NROP_DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: 构建并推送 Docker 镜像
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: registry.cn-guangzhou.aliyuncs.com/acme_nrop/vue-cicd-k8s-sample:${{ github.sha }}
|
||||
|
||||
- name: 设置 Kubernetes 工具
|
||||
uses: azure/setup-kubectl@v3
|
||||
|
||||
- name: deploy to cluster
|
||||
uses: steebchen/kubectl@v2.0.0
|
||||
with:
|
||||
config: ${{ secrets.KUBE_CONFIG_DATA }}
|
||||
command: set image --record deployment/vue-cicd-k8s-sample vue-deploy-k8s=registry.cn-guangzhou.aliyuncs.com/acme_nrop/vue-cicd-k8s-sample:${{ github.sha }}
|
||||
- name: verify deployment
|
||||
uses: steebchen/kubectl@v2.0.0
|
||||
with:
|
||||
config: ${{ secrets.KUBE_CONFIG_DATA }}
|
||||
command: rollout status deployment/vue-cicd-k8s-sample
|
||||
Reference in new issue
Block a user