Misthios/fedora intune os version defender #2
@@ -2,6 +2,12 @@ name: Build containers
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
image:
|
||||||
|
description: Image to build
|
||||||
|
type: choice
|
||||||
|
options: [all, fedora-cosmic, fedora-remote, fedora-intune]
|
||||||
|
default: all
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: ["main"]
|
branches: ["main"]
|
||||||
push:
|
push:
|
||||||
@@ -15,11 +21,17 @@ jobs:
|
|||||||
changes:
|
changes:
|
||||||
name: Compute changes
|
name: Compute changes
|
||||||
runs-on: job-v2
|
runs-on: job-v2
|
||||||
|
# The runner has no git: without it actions/checkout falls back to a
|
||||||
|
# tarball with no history, `git diff` fails and every image is rebuilt.
|
||||||
|
container:
|
||||||
|
image: "quay.io/fedora-ostree-desktops/buildroot:44"
|
||||||
outputs:
|
outputs:
|
||||||
cosmic: ${{ steps.changes.outputs.cosmic }}
|
cosmic: ${{ steps.changes.outputs.cosmic }}
|
||||||
remote: ${{ steps.changes.outputs.remote }}
|
remote: ${{ steps.changes.outputs.remote }}
|
||||||
intune: ${{ steps.changes.outputs.intune }}
|
intune: ${{ steps.changes.outputs.intune }}
|
||||||
steps:
|
steps:
|
||||||
|
- name: Install tools
|
||||||
|
run: dnf install -y nodejs git
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -27,17 +39,53 @@ jobs:
|
|||||||
- name: Detect changed images
|
- name: Detect changed images
|
||||||
id: changes
|
id: changes
|
||||||
shell: bash
|
shell: bash
|
||||||
|
env:
|
||||||
|
EVENT: ${{ github.event_name }}
|
||||||
|
BEFORE: ${{ github.event.before }}
|
||||||
|
SHA: ${{ github.sha }}
|
||||||
|
BASE_REF: ${{ github.base_ref }}
|
||||||
|
DISPATCH_IMAGE: ${{ inputs.image }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
if [[ "${{ github.event_name }}" == "push" \
|
# Diff the event's commits; any failure rebuilds everything, but
|
||||||
&& -n "${{ github.event.before }}" \
|
# say so instead of hiding it.
|
||||||
&& "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]]; then
|
diff_or_all() {
|
||||||
changed="$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" || true)"
|
if ! changed="$(git diff --name-only "$@")"; then
|
||||||
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
echo "::warning::git diff $* failed; rebuilding every image"
|
||||||
changed="$(git diff --name-only "origin/${{ github.base_ref }}...HEAD" || true)"
|
changed=""
|
||||||
else
|
elif [[ -z "${changed}" ]]; then
|
||||||
changed=""
|
# Nothing changed (e.g. an empty merge): build nothing rather
|
||||||
fi
|
# than everything.
|
||||||
|
changed="(none)"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
case "${EVENT}" in
|
||||||
|
push)
|
||||||
|
if [[ -n "${BEFORE}" && "${BEFORE}" != 0000000000000000000000000000000000000000 ]]; then
|
||||||
|
diff_or_all "${BEFORE}" "${SHA}"
|
||||||
|
else
|
||||||
|
echo "::warning::push without a previous commit; rebuilding every image"
|
||||||
|
changed=""
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
pull_request)
|
||||||
|
diff_or_all "origin/${BASE_REF}...HEAD"
|
||||||
|
;;
|
||||||
|
workflow_dispatch)
|
||||||
|
# Pretend the chosen image's directory changed; "all" (or no
|
||||||
|
# input) rebuilds everything.
|
||||||
|
if [[ -n "${DISPATCH_IMAGE}" && "${DISPATCH_IMAGE}" != all ]]; then
|
||||||
|
changed="images/${DISPATCH_IMAGE}/"
|
||||||
|
else
|
||||||
|
changed=""
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# schedule: the weekly rebuild picks up package updates for all.
|
||||||
|
changed=""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
printf 'Changed paths:\n%s\n' "${changed:-(all)}"
|
||||||
eval "$(printf '%s\n' "${changed}" | ./ci-changes.sh)"
|
eval "$(printf '%s\n' "${changed}" | ./ci-changes.sh)"
|
||||||
echo "cosmic=${cosmic}" >> "$GITHUB_OUTPUT"
|
echo "cosmic=${cosmic}" >> "$GITHUB_OUTPUT"
|
||||||
echo "remote=${remote}" >> "$GITHUB_OUTPUT"
|
echo "remote=${remote}" >> "$GITHUB_OUTPUT"
|
||||||
|
|||||||
Reference in new issue
Block a user