构建im-user镜像 #1
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
name: 构建im-user镜像 | |
on: | |
workflow_dispatch: | |
env: | |
PACKAGE_NAME: im-user | |
PACKAGE_VERSION: latest | |
DOCKERFILE_PATH: app/user/Dockerfile | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- name: 检出代码 | |
uses: actions/[email protected] | |
- name: 登录到私有仓库 | |
uses: docker/login-action@v3 | |
with: | |
registry: xu756-docker.pkg.coding.net # 声明镜像源 | |
username: xm-1727413781573 | |
password: 6f21a199cc3d8c7c2117794c829859a425bd958d | |
# - uses: docker/login-action@v3 | |
# with: | |
# registry: ghcr.io | |
# username: ${{github.actor}} | |
# password: ${{secrets.GITHUB_TOKEN}} | |
# 设置环境变量 version 为最后一次提交commit | |
- name: 设置环境变量 | |
run: echo "PACKAGE_VERSION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: 构建镜像并发布 | |
run: | |
| # 使用 上一步写的 Dockerfile 构建镜像并发布到私有仓库; 发布完成可以去 https://github.com/MrGaoGang?tab=packages 查看 | |
docker build . --file ${{env.DOCKERFILE_PATH}} --tag xu756-docker.pkg.coding.net/me/xm/${{env.PACKAGE_NAME}}:${{env.PACKAGE_VERSION}} | |
docker push xu756-docker.pkg.coding.net/me/xm/${{env.PACKAGE_NAME}}:${{env.PACKAGE_VERSION}} | |
- name: 更新服务器 发送请求 | |
run: | | |
curl -X PUT \ | |
-H "content-type: application/json" \ | |
-H "Cookie: KuboardUsername=admin; KuboardAccessKey=emrcwdmbxijy.mbxn23tmz8hmmtnnx25wab3ist3nz7nx" \ | |
-d '{"kind":"deployments","namespace":"imlogic","name":"${{env.PACKAGE_NAME}}","images":{"xu756-docker.pkg.coding.net/me/xm/${{env.PACKAGE_NAME}}":"xu756-docker.pkg.coding.net/me/xm/${{env.PACKAGE_NAME}}:${{env.PACKAGE_VERSION}}"}}' \ | |
"https://k3s.imlogic.cn/kuboard-api/cluster/default/kind/CICDApi/admin/resource/updateImageTag" |