Skip to content

01a - Compile and build the packages for Linux #13

01a - Compile and build the packages for Linux

01a - Compile and build the packages for Linux #13

Workflow file for this run

name: 'Compile and build the packages for Linux'
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
tags:
- '*'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
package-iteration:
description: 'The iteration to give to the package. RPM calls this the ‘release’. FreeBSD calls it ‘PORTREVISION’. Debian calls this ‘debian_revision’'
required: false
default: '1'
package-version:
description: 'Which tag to build for. Defaults to the current tag. Note: Specifying commits does not work, as the SHA is not the same in the monitoring-plugins and lib repo.'
required: false
default: ''
env:
# we use `${{ github.sha }}-${{ github.run_id }}_${{ github.run_attempt }}` so we get a (mostly) unique directory, to avoid folder collisions when multiple workflows are running
BASE_DIR: '${{ github.sha }}-${{ github.run_id }}_${{ github.run_attempt }}'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
prepare:
runs-on:
- 'rhel8'
- 'self-hosted'
steps:
# checkout the latest version for the build scripts
- name: 'checkout the monitoring-plugins repo'
uses: 'actions/checkout@v3'
with:
path: '${{ env.BASE_DIR }}/repos/monitoring-plugins-latest'
ref: '${{ github.ref }}' # use the current branch
# checkout the given version for the actual monitoring plugins themselves
- name: 'checkout the monitoring-plugins repo'
uses: 'actions/checkout@v3'
with:
path: '${{ env.BASE_DIR }}/repos/monitoring-plugins'
ref: '${{ inputs.package-version || github.ref }}'
- name: 'checkout the lib repo'
uses: 'actions/checkout@v3'
with:
repository: 'Linuxfabrik/lib'
ref: '${{ inputs.package-version || github.ref }}'
path: '${{ env.BASE_DIR }}/repos/lib'
- name: 'mkdir ${{ env.BASE_DIR }}/build'
run: 'mkdir ${{ env.BASE_DIR }}/build'
# Debian
build-debian12:
runs-on:
- 'rhel8'
- 'self-hosted'
needs:
- 'prepare'
steps:
- name: 'mkdir ${{ env.BASE_DIR }}/build/debian12'
run: 'mkdir ${{ env.BASE_DIR }}/build/debian12'
- name: 'Build for Debian 12'
run: |-
podman run --interactive --rm \
--mount type=bind,source=${{ env.BASE_DIR }}/build/debian12,destination=/build,relabel=private \
--mount type=bind,source=${{ env.BASE_DIR }}/repos,destination=/repos,relabel=shared,ro=true \
docker.io/library/debian:bookworm /bin/bash -x /repos/monitoring-plugins-latest/build/debian12/build.sh ${{ inputs.package-version || github.ref_name }} ${{ inputs.package-iteration || '1' }}
# this would not work on the GitHub-hosted runners, as each job is isolated there,
# but works when self-hosted (since there are no parallel jobs)
upload-outputs:
runs-on:
- 'rhel8'
- 'self-hosted'
needs: # we want this to run after the above jobs
- 'build-debian12'
if: '${{ always() }}' # however, we want to upload the artifacts even if one of the job fails
steps:
- name: 'upload the output as monitoring-plugins-linux-packages'
uses: 'actions/upload-artifact@v3'
with:
name: 'monitoring-plugins-linux-packages'
path: '${{ env.BASE_DIR }}/build/'