2024-04-01 11:07:20 -04:00
|
|
|
name: CI
|
|
|
|
run-name: ${{ github.actor }} Gitea Actions 🚀🚀🚀
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
# Sequence of patterns matched against refs/heads
|
2024-04-02 12:42:23 -04:00
|
|
|
branches:
|
|
|
|
- main
|
2024-04-01 11:07:20 -04:00
|
|
|
# Sequence of patterns matched against refs/tags
|
|
|
|
tags:
|
2024-04-02 12:42:23 -04:00
|
|
|
- v*
|
2024-04-01 11:07:20 -04:00
|
|
|
|
|
|
|
env:
|
|
|
|
# DOCKER_REGISTRY: docker.io
|
|
|
|
# DOCKER_USERNAME: softyouling
|
|
|
|
# 此处可修改为你任意 docker 镜像仓库地址和用户名
|
|
|
|
|
|
|
|
DOMAIN: gitea.lntu.edu.cn
|
2024-04-01 13:20:55 -04:00
|
|
|
# IMAGE_NAME: code/demo/demo
|
2024-04-01 11:07:20 -04:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
2024-04-02 12:45:44 -04:00
|
|
|
runs-on: k8s # <-- Used runner label
|
2024-04-02 13:02:13 -04:00
|
|
|
container: ghcr.m.daocloud.io/catthehacker/ubuntu:custom-20.04-20240401
|
2024-04-01 11:07:20 -04:00
|
|
|
steps:
|
2024-04-02 12:42:23 -04:00
|
|
|
# - name: 环境检测
|
|
|
|
# run: |
|
|
|
|
# which node
|
|
|
|
# node --version
|
|
|
|
# which npm
|
|
|
|
# npm --version
|
|
|
|
# which docker
|
|
|
|
# docker info
|
|
|
|
# echo ${{ github.token }}
|
|
|
|
# echo ${{ env.GITOPS_URL }}
|
2024-04-01 11:07:20 -04:00
|
|
|
|
2024-04-02 12:42:23 -04:00
|
|
|
- name: 拉取代码
|
|
|
|
uses: https://${{ env.DOMAIN }}/actions/checkout@v4
|
2024-04-01 11:07:20 -04:00
|
|
|
|
2024-04-02 12:42:23 -04:00
|
|
|
# Docker配置多平台环境
|
|
|
|
# - name: Docker配置多平台环境
|
|
|
|
# uses: https://${{ env.DOMAIN }}/actions/setup-buildx-action@v3
|
2024-04-01 11:07:20 -04:00
|
|
|
|
2024-04-02 12:42:23 -04:00
|
|
|
# - name: 获取当前时间
|
|
|
|
# id: date
|
|
|
|
# run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')"
|
2024-04-01 11:07:20 -04:00
|
|
|
|
2024-04-02 12:42:23 -04:00
|
|
|
# - name: 构建 & 推送镜像
|
|
|
|
# uses: https://${{ env.DOMAIN }}/actions/docker-build-push@v6
|
|
|
|
# with:
|
|
|
|
# image: ${{ gitea.repository }}
|
|
|
|
# tags: ${{ github.sha }}
|
|
|
|
# registry: softyouling-docker.pkg.coding.net
|
|
|
|
# enableBuildKit: true
|
|
|
|
# # multiPlatform: true
|
|
|
|
# # platform: linux/amd64,linux/arm64,linux/arm/v7
|
|
|
|
# dockerfile: Dockerfile
|
|
|
|
# username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
# password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: 🐬镜像构建推送
|
|
|
|
uses: https://${{ env.DOMAIN }}/actions/docker-build-push@main
|
|
|
|
with:
|
|
|
|
image: ${{ gitea.repository }}
|
|
|
|
tags: ${{ gitea.sha }}
|
|
|
|
registry: ${{ env.DOMAIN }}
|
|
|
|
# enableBuildKit: true
|
|
|
|
provenance: false
|
|
|
|
dockerfile: Dockerfile
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
2024-04-01 11:07:20 -04:00
|
|
|
gtiops:
|
2024-04-02 12:45:44 -04:00
|
|
|
runs-on: k8s # <-- Used runner label
|
2024-04-02 13:02:13 -04:00
|
|
|
container: ghcr.m.daocloud.io/catthehacker/ubuntu:custom-20.04-20240401
|
2024-04-01 11:07:20 -04:00
|
|
|
if: ${{ success() }}
|
|
|
|
needs: [build]
|
|
|
|
|
2024-04-01 14:38:40 -04:00
|
|
|
steps:
|
2024-04-02 12:42:23 -04:00
|
|
|
- name: 🐬更新应用镜像
|
|
|
|
uses: http://gitea.lntu.edu.cn/actions/gitops@main
|
|
|
|
with:
|
|
|
|
email: "gitops@lntu.edu.cn"
|
|
|
|
name: "千里走单骑"
|
|
|
|
value: ${{ gitea.repository }}
|
|
|
|
tag: ${{ github.sha }}
|
|
|
|
url: ${{ env.DOMAIN }}/${{ secrets.GITOPS_REPO}}
|
|
|
|
filename: ${{ secrets.FILE_NAME }}
|
|
|
|
token: ${{ secrets.GITOPS_TOKEN }}
|
2024-04-01 11:07:20 -04:00
|
|
|
|
|
|
|
微信通知:
|
2024-04-02 12:45:44 -04:00
|
|
|
runs-on: k8s # <-- Used runner label
|
2024-04-02 13:02:13 -04:00
|
|
|
container: ghcr.m.daocloud.io/catthehacker/ubuntu:custom-20.04-20240401
|
2024-04-01 11:07:20 -04:00
|
|
|
if: ${{success()}}
|
|
|
|
needs: [build, gtiops]
|
|
|
|
|
|
|
|
steps:
|
2024-04-02 12:42:23 -04:00
|
|
|
# 发送通知
|
|
|
|
- name: 微信通知
|
|
|
|
uses: https://${{ env.DOMAIN }}/actions/action-wechat-work@master
|
|
|
|
# 若没有配置机器人WebHook则跳过
|
|
|
|
if: ${{ secrets.WECHAT_WORK_BOT_WEBHOOK != '' }}
|
|
|
|
env:
|
|
|
|
WECHAT_WORK_BOT_WEBHOOK: ${{ secrets.WECHAT_WORK_BOT_WEBHOOK }}
|
|
|
|
with:
|
|
|
|
msgtype: markdown
|
|
|
|
content: "✅ 应用版本更新成功\n > 🐬 镜像:\n > softyouling-docker.pkg.coding.net/code/demo/demo:${{ github.sha }}\n > 🍏 就能帮你到这了"
|