build_layer3 #253
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 App Layer (3 of 4)" | |
on: | |
repository_dispatch: | |
types: [build_layer3, build_layer2_error] | |
env: | |
IMAGE_STAGE: pyapp | |
DOCKERFILE2USE: docker/dfstage-pyapp.dockerfile | |
FROM_LAYER: ${{ github.event.client_payload.layer2 }} | |
FROM_LAYER_TAG: ${{ github.event.client_payload.layer2tag }} | |
jobs: | |
build_result: | |
name: "Build Layer 2 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 }} | |
VERSION_TAG: ${{ steps.config_step.outputs.VERSION_TAG }} | |
VER_NUM: ${{ steps.config_step.outputs.VER_NUM }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.client_payload.repo.ref_name }} | |
- name: "Determine Tag To Use" | |
id: config_step | |
shell: bash | |
env: | |
REF_NAME: "${{ github.event.client_payload.repo.ref_name }}" | |
run: |- | |
IMAGE_NAME=${{ github.repository_owner }}/p4-engage | |
VERSION_STR=$(cat VERSION) | |
if [[ "${{ github.event.client_payload.repo.ref_type }}" == "tag" ]]; then | |
IMAGE_TAG_HASH="${REF_NAME#*v}" | |
elif [[ "${REF_NAME}" == "develop" ]]; then | |
IMAGE_TAG_HASH="ci-develop" | |
elif [ "${REF_NAME}" != "master" ] && [ "${REF_NAME}" != "main" ]; then | |
IMAGE_TAG_HASH="ci-${VERSION_STR}-${REF_NAME#**/}" | |
else | |
IMAGE_TAG_HASH="ci-${VERSION_STR}" | |
fi | |
IMAGE_TAG="${IMAGE_STAGE}-${IMAGE_TAG_HASH}" | |
VER_BUILD=$(date +%H%M) | |
VER_NUM="$(date +%y).$(date +%m).$(date +%d).${VER_BUILD:0:3}" | |
VER_INT=${VER_NUM//.} | |
echo "::notice::Version Timestamp=${VER_NUM}" | |
echo "VER_NUM=${VER_NUM}" >> $GITHUB_OUTPUT | |
echo "::notice::Layer3: ${IMAGE_NAME}:${IMAGE_TAG}" | |
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_OUTPUT | |
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_OUTPUT | |
echo "VERSION_TAG=${IMAGE_TAG_HASH}" >> $GITHUB_OUTPUT | |
#endjob build_cfg | |
trigger-build: | |
runs-on: ubuntu-latest | |
needs: [build_cfg] | |
environment: default | |
steps: | |
- name: Trigger Container Build | |
uses: peter-evans/repository-dispatch@v2 | |
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": "amd64 arm64", | |
"name": "${{ needs.build_cfg.outputs.IMAGE_NAME }}", | |
"tag": "${{ needs.build_cfg.outputs.IMAGE_TAG }}", | |
"build_args": [ | |
"FROM_STAGE=${{ env.FROM_LAYER }}", | |
"FROM_STAGE_TAG=${{ env.FROM_LAYER_TAG }}", | |
"VERSION_CI=${{ needs.build_cfg.outputs.VER_NUM }}", | |
"VERSION_TAG=${{ needs.build_cfg.outputs.VERSION_TAG }}" | |
] | |
}, | |
"callback": { | |
"repository": "${{ github.repository }}", | |
"event_type": "build_layer4", | |
"error_type": "build_layer3_error", | |
"payload": { | |
"repo": { | |
"ref_type": "${{ github.event.client_payload.repo.ref_type }}", | |
"ref_name": "${{ github.event.client_payload.repo.ref_name }}" | |
}, | |
"image": { | |
"tag": "${{ needs.build_cfg.outputs.VERSION_TAG }}", | |
"ver_num": "${{ needs.build_cfg.outputs.VER_NUM }}", | |
"layer3tag": "${{ needs.build_cfg.outputs.IMAGE_TAG }}", | |
"layer3": "${{ needs.build_cfg.outputs.IMAGE_NAME }}:${{ needs.build_cfg.outputs.IMAGE_TAG }}" | |
} | |
} | |
} | |
} | |
#endjob trigger-build |