|
4 | 4 | tags: 'v*' |
5 | 5 |
|
6 | 6 | jobs: |
7 | | - build-package: |
| 7 | + build-image: |
8 | 8 | runs-on: ubuntu-latest |
| 9 | + outputs: |
| 10 | + image: ${{ steps.get_image.outputs.IMAGE }} |
9 | 11 | steps: |
10 | 12 | - uses: actions/checkout@v4 |
| 13 | + # docker login is needed for pushing the test image |
| 14 | + - uses: docker/login-action@v3 |
| 15 | + with: |
| 16 | + registry: ghcr.io |
| 17 | + username: ${{ github.actor }} |
| 18 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 19 | + - id: get_hash |
| 20 | + run: echo "HASH=$(find mkp -type f -printf '%p:%s' | xargs | md5sum | cut -d\ -f1)" >> $GITHUB_OUTPUT |
| 21 | + - id: get_image |
| 22 | + run: echo "IMAGE=$(echo ghcr.io/${{ github.repository }} | tr '[:upper:]' '[:lower:]'):${{ steps.get_hash.outputs.HASH }}" >> $GITHUB_OUTPUT |
| 23 | + - run: echo "image ${{ steps.get_image.outputs.IMAGE }}" |
11 | 24 | # build container image for package creation |
12 | | - - run: /usr/bin/docker build -t ${{ github.job }} -f build/Dockerfile . |
13 | | - # actually build .mkp file |
14 | | - - run: /usr/bin/docker run --volume $PWD:/source ${{ github.job }} |
| 25 | + - run: docker pull ${{ steps.get_image.outputs.IMAGE }} || docker build -t ${{ steps.get_image.outputs.IMAGE }} -f dockerfiles/checkmk/Dockerfile . |
| 26 | + - run: docker push ${{ steps.get_image.outputs.IMAGE }} |
| 27 | + |
| 28 | + build-package: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + needs: build-image |
| 31 | + container: |
| 32 | + image: ${{ needs.build-image.outputs.image }} |
| 33 | + env: |
| 34 | + CMK: /omd/sites/cmk |
| 35 | + SU: su - cmk -c |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + - run: cp -r mkp/local/* ${CMK}/local |
| 39 | + - run: ${SU} "mkdir ${CMK}/tmp/check_mk" |
| 40 | + - run: ${SU} "mkp template yum" |
| 41 | + - run: git config --global --add safe.directory ${PWD} |
| 42 | + - run: modify-extension.py ${PWD} ${CMK}/tmp/check_mk/yum.manifest.temp |
| 43 | + # avoid error: |
| 44 | + # Error removing file /omd/sites/cmk/local/lib/python3/cmk/base/cee/plugins/bakery/yum.py: [Errno 13] Permission denied: '/omd/sites/cmk/local/lib/python3/cmk/base/cee/plugins/bakery/yum.py' |
| 45 | + # and likewise the `mkp package` fails due to already existing files |
| 46 | + - run: chmod go+rw ${CMK}/local/lib/python3/cmk/base/cee/plugins/bakery |
| 47 | + - run: chmod go+rw ${CMK}/local/lib/python3/cmk_addons/plugins/yum/agent_based |
| 48 | + - run: chmod go+rw ${CMK}/local/lib/python3/cmk_addons/plugins/yum/checkman |
| 49 | + - run: chmod go+rw ${CMK}/local/lib/python3/cmk_addons/plugins/yum/rulesets |
| 50 | + - run: cat ${CMK}/tmp/check_mk/yum.manifest.temp |
| 51 | + - run: ${SU} "mkp package ${CMK}/tmp/check_mk/yum.manifest.temp" |
| 52 | + # copy created extension package back to workspace |
| 53 | + - run: cp ${CMK}/var/check_mk/packages_local/*.mkp ${PWD}/mkp/ |
15 | 54 | # upload results |
16 | 55 | - uses: actions/upload-artifact@v4 |
17 | 56 | with: |
18 | | - path: ./*.mkp |
| 57 | + path: ./mkp/*.mkp |
19 | 58 | retention-days: 1 |
20 | 59 |
|
21 | 60 | github-release: |
|
0 commit comments