线上pipeline,(我使用是本地仓库的,你们使用切换成官网的即可)
# 工作流的名称name: Build and Push Docker Image deployment-k8s
# 触发条件,只在 master 或 main 分支发送推送时触发on:push:branches:- main
# 作业,工作流运行由一个或多个 jobs 组成,默认情况下并行运行jobs:build-and-push-image:# 定义要运行作业的计算机类型runs-on: ubuntu-latest
steps:# 检出代码-name: Checkout Code
#uses: actions/checkout@v4uses: http://192.168.0.20:3000/admins/checkout@main
# 设置 Docker BuildX-name: Set up Docker Buildx
id: buildx
#uses: docker/[email protected]: http://192.168.0.20:3000/admins/[email protected]
# 登录 Registry -name: Login to DockerHub
#uses: docker/login-action@v2uses: http://192.168.0.20:3000/admins/login-action@v3
with:registry: ${{ secrets.REGISTRY }}username: ${{ secrets.DOCKER_USERNAME }}password: ${{ secrets.DOCKER_PASSWORD }}# 构建并推送 Docker 镜像-name: Build Docker Image
id: docker_build
uses: http://192.168.0.20:3000/admins/build-push-action@v4
#uses: docker/build-push-action@v4with:push:truefile: ./Dockerfile-uat
tags: ${{ secrets.REGISTRY_PATH }}/www:${{ github.sha }}# 部署k8s-name: deploy to cluster
#uses: actions-hub/kubectl@masteruses: http://192.168.0.20:3000/admins/kubectl@main
env:KUBE_CONFIG: ${{ secrets.KUBE_CONFIG_DATA_160 }}with:args: set image deployment/www-web www-web=${{ secrets.REGISTRY_PATH }}/www:${{ github.sha }}-n test
-name: verify deployment
uses: http://192.168.0.20:3000/admins/kubectl@main
env:KUBE_CONFIG: ${{ secrets.KUBE_CONFIG_DATA_160 }}with:args: rollout status deployment/www-web -n test
流水线变量 — 设置>>>> Runner >>> 密钥(输入你的变量)
注意原生使用k8s,然后在加入变量中
cat $HOME/.kube/config | base64
如果你是AWS EKS如下简单配置使用专门EKS镜像:
- name: Deploy Application
uses: statsig-io/kubectl-via-eksctl@main
env:aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID}}aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}region: ap-northeast-1cluster: ${{ secrets.CLUSTER_NAME}}with:args:get pods -n prometheus
#args:set image deployment/my-app container=${{ github.repository}}:${{ github.sha }}
Gitea Action工具链更丰富以下是他的市场和工具链,大家可以自己选择自己喜欢的工具
#镜像包
https://github.com/actions/runner-images?tab=readme-ov-file#available-images
#入门文档
https://docs.github.com/zh/actions/writing-workflows/quickstart
#市场
https://github.com/marketplace?type=actions
最后还可以加入一个webhook,目前只找到一个飞书的
-name: Send Text Message
#uses: foxundermoon/feishu-action@v2uses: http://192.168.0.20:3000/admins/feishu-action@v2
with:url: ${{ secrets.FEISHU_BOT_WEBHOOK_URL }}msg_type: text
content:|
text: |
发布者/项目名: ${{ github.repository }}
项目状态: ${{ job.status }}
本文转载自: https://blog.csdn.net/weixin_42562106/article/details/142174469
版权归原作者 野猪佩挤 所有, 如有侵权,请联系我们删除。
版权归原作者 野猪佩挤 所有, 如有侵权,请联系我们删除。