Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 35 additions & 87 deletions .github/workflows/pre-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ jobs:
permissions:
contents: read
needs: pre-checks
if: ${{ contains(needs.pre-checks.outputs.other_changed_projects, 'os-profiles') }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -153,107 +152,56 @@ jobs:
aws-region: us-west-2
- name: "Curate OS profile"
run: |
set -euo pipefail
sed -i 's/-dev//g' VERSION

for yaml in os-profiles/microvisor-rt.yaml os-profiles/microvisor-nonrt.yaml; do
echo "Processing YAML: $yaml"
echo "🧩 Processing YAML: $yaml"

manifest_url=$(sed -n 's/^[[:space:]]*osPackageManifestURL:[[:space:]]*\(.*\)$/\1/p' "$yaml")
if [[ -z "$manifest_url" ]]; then
echo "⚠️ No manifest URL found in $yaml — skipping"
continue
fi

full_url="https://files-rs.edgeorchestration.intel.com/${manifest_url}"
manifest_file="${manifest_url##*/}"
echo "Downloading manifest from ${full_url}..."

echo "📥 Downloading manifest from ${full_url}..."
if ! curl -sfL "$full_url" -o "$manifest_file"; then
echo "❌ Failed to download $full_url — skipping $yaml"
continue
fi

k3s_version=$(jq -r '.Repo[] | select(.Name=="k3s") | .Version' "$manifest_file" | cut -d'-' -f1)
if [[ -z "$k3s_version" ]]; then
echo "⚠️ k3s not found in $manifest_file — skipping $yaml"
if [[ -z "$k3s_version" || "$k3s_version" == "null" ]]; then
echo "⚠️ No k3s version found in $manifest_file — skipping $yaml"
continue
fi
echo "✅ Found k3s version: v${k3s_version}"

sed -i \
-e 's/^ version:.*$/ kubernetesVersion: v'"$k3s_version"'/' \
-e 's/^ kubernetes-version:.*$/ kubernetesVersion: v'"$k3s_version"'/' "$yaml"
done
cat VERSION; cat os-profiles/microvisor-rt.yaml; cat os-profiles/microvisor-nonrt.yaml
- name: "Run validate OS profile"
run: |
cd .github/workflows/scripts && ./validate_os_profiles.sh ${{ secrets.S3_NAME }}
# TODO: generalize this part of the CI for all subcomponents
- name: "Get PR Description"
id: get_pr_description
run: |
PR_DESCRIPTION=$(curl -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" \
| jq -r '.body')
# Normalize the os-profile YAML field consistently
sed -i -E \
-e "s/^[[:space:]]*kubernetes-version:[[:space:]]*.*/ kubernetesVersion: v${k3s_version}/" \
-e "s/^[[:space:]]*kubernetesVersion:[[:space:]]*.*/ kubernetesVersion: v${k3s_version}/" \
"$yaml"

PUBLISH=$(echo "$PR_DESCRIPTION" | grep -q '/publish🚢' && echo true || echo false)
echo $PUBLISH
echo "PUBLISH=$PUBLISH" >> $GITHUB_ENV
- name: Configure AWS credentials
if: ${{ env.PUBLISH == 'true' }}
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8 # v5.1.0
with:
aws-access-key-id: ${{ secrets.NO_AUTH_ECR_PUSH_USERNAME }}
aws-secret-access-key: ${{ secrets.NO_AUTH_ECR_PUSH_PASSWD }}
aws-region: us-west-2
- name: Login to Amazon ECR
if: ${{ env.PUBLISH == 'true' }}
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
with:
registries: "080137407410"
- if: ${{ env.PUBLISH == 'true'}}
name: "Publish OS profiles for development purposes"
working-directory: "os-profiles"
run: |
TAGS=$(git rev-parse --abbrev-ref HEAD | sed 's/\//_/g') make artifact-publish
- if: ${{ env.PUBLISH == 'true' }}
name: "Publish comment to PR"
working-directory: "os-profiles"
run: |
ALL_PROFILES=$(find *.yaml)
OCI_REPOSITORY="edge-orch/en/files/os-profile"
REGISTRY="registry-rs.edgeorchestration.intel.com"
TAG=$(git rev-parse --abbrev-ref HEAD | sed 's/\//_/g')
COMMENT="🚀🚀 Published OSProfiles with tag \"${TAG}\"!"
for profile in $ALL_PROFILES; do
COMMENT+="\n- oci://${REGISTRY}/${OCI_REPOSITORY}/${profile}:${TAG}"
done
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
--data "{\"body\": \"$COMMENT\"}" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"

final-check:
permissions:
contents: read
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [pre-merge-root, pre-merge-pipeline, pre-merge-os-profiles, pre-merge-os-profiles-2]
steps:
- name: Final Status Check
env:
pre_merge_root_pipeline: ${{ needs.pre-merge-root.result }}
pre_merge_pipeline: ${{ needs.pre-merge-pipeline.result }}
pre_merge_os_profiles: ${{ needs.pre-merge-os-profiles.result }}
pre_merge_os_profiles_2: ${{ needs.pre-merge-os-profiles-2.result }}
run: |
results=("pre_merge_root_pipeline" "pre_merge_pipeline" "pre_merge_os_profiles" "pre_merge_os_profiles_2")
status="OK"
# If key doesn’t exist at all, insert it under metadata
if ! grep -q 'kubernetesVersion:' "$yaml"; then
echo "⚠️ kubernetesVersion not found — inserting new key"
awk -v ver="v${k3s_version}" '/^metadata:/{print;print " kubernetesVersion: " ver;next}1' "$yaml" > tmp && mv tmp "$yaml"
fi

for result in "${results[@]}"; do
pipeline_result=$(eval echo \$$result)
echo "${result} result: $pipeline_result"
if [[ "$pipeline_result" != "success" && "$pipeline_result" != "skipped" ]]; then
status="KO"
# Final validation
if ! grep -q 'kubernetesVersion:' "$yaml"; then
echo "❌ kubernetesVersion missing after update in $yaml"
exit 1
fi
echo "✅ Updated $yaml with kubernetesVersion: v${k3s_version}"
done

if [[ "$status" == "OK" ]]; then
echo "Pre-merge check passed successfully."
else
echo "All pre-merge checks failed or were skipped. PR can't get merged"
exit 1
fi
echo "----- VERSION -----"
cat VERSION
echo "----- microvisor-rt.yaml -----"
cat os-profiles/microvisor-rt.yaml
echo "----- microvisor-nonrt.yaml -----"
cat os-profiles/microvisor-nonrt.yaml