ingress #6
Workflow file for this run
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: ingress | |
permissions: | |
contents: read | |
on: | |
push: | |
branches: [ ingress ] | |
workflow_dispatch: | |
inputs: | |
script_version: | |
description: 'script version, only support 1.9 or 0.49' | |
required: true | |
default: '1.9' | |
branch: | |
description: 'branch or tag name, should compatibe with SCRIPT_VERSION' | |
required: true | |
default: 'release-1.9' | |
arch: | |
description: 'arch' | |
required: true | |
default: 'amd64' | |
env: | |
PROJECT: ingress-nginx | |
BRANCH: release-1.9 # NOTICE, SCRIPT_VERSION must comtible | |
ARCH: amd64 | |
SCRIPT_VERSION: 1.9 | |
REGISTRY_NAME: "docker.io" | |
REGISTRY_USER: "${{ secrets.DOCKER_HUB_USER }}" | |
REGISTRY_PASS: "${{ secrets.DOCKER_HUB_PASSWORD }}" | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setting | |
run: | | |
set -x | |
if ${{ github.event_name == 'workflow_dispatch' }} ; then | |
echo "BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV | |
echo "SCRIPT_VERSION=${{ github.event.inputs.script_version }}" >> $GITHUB_ENV | |
echo "ARCH=${{ github.event.inputs.arch }}" >> $GITHUB_ENV | |
fi | |
echo "trigger by ${{ github.event_name }}" | |
echo "BRANCH is ${{ env.BRANCH }}" | |
echo "SCRIPT_VERSION is ${{ env.SCRIPT_VERSION }}" | |
echo "ARCH is ${{ env.ARCH }}" | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Check out repo code | |
uses: actions/checkout@v4 | |
- name: Check out build code | |
uses: actions/checkout@v4 | |
with: | |
repository: easystack/${{ env.PROJECT }} | |
ref: ${{ env.BRANCH }} | |
token: ${{ secrets.KPULL }} | |
path: ${{ env.PROJECT }} | |
- name: Login to Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY_NAME }} | |
username: ${{ env.REGISTRY_USER }} | |
password: ${{ env.REGISTRY_PASS }} | |
- name: Image Build And Push | |
shell: bash | |
run: | | |
set -ex | |
# 覆盖默认build.sh, 支持 sm 密码 ssl 库 | |
cp -f ingress/build-${{ env.SCRIPT_VERSION }}.sh ${{ env.PROJECT }}/images/nginx/rootfs/build.sh | |
# 删除 openssl 相关 | |
sed -i '/openssl/d' ${{ env.PROJECT }}/images/nginx/rootfs/Dockerfile | |
# build | |
cd ${{ env.PROJECT }} | |
export REGISTRY=${{ env.REGISTRY_NAME }}/yylt | |
export BASE_IMAGE=${{ env.REGISTRY_NAME }}/yylt/ingress:${{ env.ARCH }}-base-${{ env.SCRIPT_VERSION }} | |
# base base image | |
docker buildx build \ | |
--no-cache \ | |
--platform linux/${{ env.ARCH }} \ | |
--output "type=image,push=true" \ | |
--tag ${BASE_IMAGE} \ | |
--file ./images/nginx/rootfs/Dockerfile ./images/nginx/rootfs | |
# build ingress image | |
export ARCH=${{ env.ARCH }} | |
export PLATFORM=linux/${{ env.ARCH }} | |
make build && make image | |
docker tag ${REGISTRY}/controller:$(cat TAG) ${REGISTRY}/ingress:${ARCH}-${{ env.SCRIPT_VERSION }} | |
docker push ${REGISTRY}/ingress:${ARCH}-${{ env.SCRIPT_VERSION }} |