mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-07-02 23:23:21 +00:00
perf: add jms_ansible_ee CI workflow and refine EE build
This commit is contained in:
95
.github/workflows/build-jms-ansible-ee.yml
vendored
Normal file
95
.github/workflows/build-jms-ansible-ee.yml
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
name: Build and Push Ansible EE Image
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- 'dev'
|
||||
- 'v*'
|
||||
paths:
|
||||
- utils/ansible_executor/**
|
||||
- apps/libs/ansible/**
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
- reopened
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
branch:
|
||||
description: '构建 Ansible EE 镜像所用的分支'
|
||||
required: true
|
||||
type: string
|
||||
default: 'main'
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Lock Pull Request
|
||||
if: github.event_name == 'push'
|
||||
run: |
|
||||
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||
-d '{"state":"pending", "description":"Action running, merge disabled", "context":"Lock PR"}' \
|
||||
"https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }}"
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.ref }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Extract date
|
||||
id: vars
|
||||
run: echo "IMAGE_TAG=$(date +'%Y%m%d_%H%M%S')" >> $GITHUB_ENV
|
||||
|
||||
- name: Install ansible-builder
|
||||
run: pip install 'ansible-builder>=3.1.1'
|
||||
|
||||
- name: Create EE build context
|
||||
working-directory: utils/ansible_executor
|
||||
run: |
|
||||
ansible-builder create \
|
||||
-f execution-environment.yml \
|
||||
-c context \
|
||||
--container-runtime docker
|
||||
|
||||
- name: Build and push multi-arch image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
context: utils/ansible_executor/context
|
||||
file: utils/ansible_executor/context/Dockerfile
|
||||
tags: jumpserver/jms_ansible_ee:${{ env.IMAGE_TAG }}
|
||||
|
||||
- name: Update runner.py
|
||||
run: |
|
||||
sed -i "s|ANSIBLE_EE_IMAGE = .*|ANSIBLE_EE_IMAGE = 'jumpserver/jms_ansible_ee:${{ env.IMAGE_TAG }}'|" apps/ops/ansible/runner.py
|
||||
|
||||
- name: Commit changes
|
||||
run: |
|
||||
git config --global user.name 'github-actions[bot]'
|
||||
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
||||
git add apps/ops/ansible/runner.py
|
||||
git commit -m "perf: Update Ansible EE image tag in runner.py"
|
||||
git push
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Unlock Pull Request
|
||||
if: github.event_name == 'push'
|
||||
run: |
|
||||
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||
-d '{"state":"success", "description":"Action running, merge disabled", "context":"Lock PR"}' \
|
||||
"https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }}"
|
||||
Reference in New Issue
Block a user