build_layer_lib #235
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: "Build (2 of 6) Lib Layer" | |
on: | |
repository_dispatch: | |
types: [build_layer_lib, build_layer_os_error] | |
env: | |
IMAGE_STAGE: pylibs | |
DOCKERFILE2USE: docker/dfstage-pylibs.dockerfile | |
FROM_LAYER: ${{ github.event.client_payload.layer }} | |
FROM_LAYER_TAG: ${{ github.event.client_payload.layer_tag }} | |
jobs: | |
build_result: | |
name: "Build OS Layer Result [#${{ github.event.client_payload.run_number }}]" | |
runs-on: ubuntu-latest | |
env: | |
RUN_URL: "[Run #${{ github.event.client_payload.run_number }}](${{ github.event.client_payload.run_url }})" | |
steps: | |
- name: "Display Error Msg" | |
if: github.event.client_payload.error_msg != '' | |
run: |- | |
echo -e "::error::${RUN_URL}%0A${{ github.event.client_payload.error_msg }}" | |
exit 1 | |
- name: "Display Success Msg" | |
if: github.event.client_payload.build_msg != '' | |
run: |- | |
echo -e "::notice::${RUN_URL}%0A${{ github.event.client_payload.build_msg }}" | |
#endjob build_result | |
build_cfg: | |
needs: [build_result] | |
runs-on: ubuntu-latest | |
environment: default | |
outputs: | |
IMAGE_NAME: ${{ steps.config_step.outputs.IMAGE_NAME }} | |
IMAGE_TAG: ${{ steps.config_step.outputs.IMAGE_TAG }} | |
FLOW_EDITOR: ${{ steps.config_step.outputs.FLOW_EDITOR }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.client_payload.repo.ref_name }} | |
- name: "Determine Tag To Use" | |
id: config_step | |
run: |- | |
IMAGE_NAME=${{ github.repository_owner }}/p4-engage | |
echo "${FROM_LAYER#**:}" > base_tag.txt | |
source scm/utils.sh | |
IMAGE_TAG_HASH=$(CalcFileArgsMD5 "${DOCKERFILE2USE}" "base_tag.txt" "poetry.lock" "pyproject.toml" "package-lock.json" "package.json" "VERSION_FlowEditor") | |
IMAGE_TAG="${IMAGE_STAGE}-${IMAGE_TAG_HASH}" | |
echo "::notice::Lib Layer: ${IMAGE_NAME}:${IMAGE_TAG}" | |
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_OUTPUT | |
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_OUTPUT | |
FLOW_EDITOR=$(cat VERSION_FlowEditor) | |
echo "FLOW_EDITOR=${FLOW_EDITOR#v}" >> $GITHUB_OUTPUT | |
#endjob build_cfg | |
check_image_exist: | |
needs: [build_cfg] | |
uses: ./.github/workflows/util-docker-image-exists.yml | |
secrets: inherit | |
with: | |
name: ${{ needs.build_cfg.outputs.IMAGE_NAME }} | |
tag: ${{ needs.build_cfg.outputs.IMAGE_TAG }} | |
#endjob check_image_exist | |
check_build_image: | |
runs-on: ubuntu-latest | |
needs: [check_image_exist] | |
environment: default | |
env: | |
BUILD_ERR_MSG: ${{ needs.check_image_exist.outputs.err_msg }} | |
outputs: | |
BUILD_STAGE: ${{ steps.is_building.outputs.BUILD_STAGE }} | |
steps: | |
- name: Set BUILD_STAGE output | |
id: is_building | |
run: |- | |
if [[ -n "${BUILD_ERR_MSG}" ]]; then | |
echo "${BUILD_ERR_MSG}" | |
exit 1 | |
fi | |
if [[ '${{ needs.check_image_exist.outputs.exists }}' == '0' ]]; then | |
BUILD_STAGE=1 | |
else | |
BUILD_STAGE=0 | |
fi | |
echo "::notice::Build Stage?=${BUILD_STAGE}" | |
echo "BUILD_STAGE=${BUILD_STAGE}" >> $GITHUB_OUTPUT | |
#endjob check_build_image | |
trigger-build: | |
if: needs.check_build_image.outputs.BUILD_STAGE == 1 | |
runs-on: ubuntu-latest | |
needs: [build_cfg, check_build_image] | |
environment: default | |
steps: | |
- name: Trigger Container Build | |
uses: peter-evans/repository-dispatch@v3 | |
with: | |
token: ${{ secrets.CI_WEBHOOK_TOKEN }} | |
repository: istresearch/ci-docker | |
event-type: build-repo | |
client-payload: |- | |
{ | |
"repo": { | |
"name": "${{ github.repository }}", | |
"ref_type": "${{ github.event.client_payload.repo.ref_type }}", | |
"ref_name": "${{ github.event.client_payload.repo.ref_name }}" | |
}, | |
"image": { | |
"dockerfile": "${{ env.DOCKERFILE2USE }}", | |
"arch_allowed": "${{ github.event.client_payload.arch_allowed }}", | |
"name": "${{ needs.build_cfg.outputs.IMAGE_NAME }}", | |
"tag": "${{ needs.build_cfg.outputs.IMAGE_TAG }}", | |
"build_args": [ | |
"FROM_STAGE=${{ env.FROM_LAYER }}", | |
"FLOW_EDITOR=${{ needs.build_cfg.outputs.FLOW_EDITOR }}", | |
"REPO_UN=%REPO_UN", | |
"REPO_PW=%REPO_PW" | |
] | |
}, | |
"deployment": { | |
"deploy_flag": "0" | |
}, | |
"callback": { | |
"repository": "${{ github.repository }}", | |
"event_type": "build_layer_app", | |
"error_type": "build_layer_lib_error", | |
"payload": { | |
"repo": { | |
"ref_type": "${{ github.event.client_payload.repo.ref_type }}", | |
"ref_name": "${{ github.event.client_payload.repo.ref_name }}" | |
}, | |
"layer_tag": "${{ needs.build_cfg.outputs.IMAGE_TAG }}", | |
"layer": "${{ needs.build_cfg.outputs.IMAGE_NAME }}:${{ needs.build_cfg.outputs.IMAGE_TAG }}", | |
"arch_allowed": "${{ github.event.client_payload.arch_allowed }}", | |
"version": { | |
"str": "${{ github.event.client_payload.version.str }}", | |
"int": "${{ github.event.client_payload.version.int }}", | |
"kind": "${{ github.event.client_payload.version.kind }}", | |
"alt": "${{ github.event.client_payload.version.alt }}" | |
} | |
} | |
} | |
} | |
#endjob trigger-build | |
trigger-next-stage: | |
if: needs.check_build_image.outputs.BUILD_STAGE == 0 | |
runs-on: ubuntu-latest | |
needs: [build_cfg, check_build_image] | |
environment: default | |
steps: | |
- name: "Trigger Next Stage" | |
uses: peter-evans/repository-dispatch@v3 | |
with: | |
event-type: build_layer_app | |
client-payload: |- | |
{ | |
"repo": { | |
"ref_type": "${{ github.event.client_payload.repo.ref_type }}", | |
"ref_name": "${{ github.event.client_payload.repo.ref_name }}" | |
}, | |
"layer_tag": "${{ needs.build_cfg.outputs.IMAGE_TAG }}", | |
"layer": "${{ needs.build_cfg.outputs.IMAGE_NAME }}:${{ needs.build_cfg.outputs.IMAGE_TAG }}", | |
"arch_allowed": "${{ github.event.client_payload.arch_allowed }}", | |
"version": { | |
"str": "${{ github.event.client_payload.version.str }}", | |
"int": "${{ github.event.client_payload.version.int }}", | |
"kind": "${{ github.event.client_payload.version.kind }}", | |
"alt": "${{ github.event.client_payload.version.alt }}" | |
} | |
} | |
#endjob trigger-next-stage |