Skip to content

.github/workflows/update_from_schema.yaml #246

.github/workflows/update_from_schema.yaml

.github/workflows/update_from_schema.yaml #246

# This workflow updates xjoin-schema to support the latest changes to
# the system_profile schema from inventory-schemas.
# The workflow is triggered by a workflow in the inventory-schema repo
# that runs when a change to the system profile schema is merged.
name: update mapping
on:
schedule:
- cron: "5 0 * * *"
workflow_dispatch:
jobs:
update_mapping:
runs-on: ubuntu-latest
steps:
- name: Check out xjoin-config
uses: actions/checkout@v3
- name: Run docker-compose up elasticsearch
uses: isbang/compose-action@v1.4.1
with:
compose-file: "./docker-compose.yml"
services: elasticsearch
- name: Check out schema repo to copy current schema from
uses: actions/checkout@v3
with:
repository: RedHatInsights/inventory-schemas
path: ./inventory-schemas-upstream
- name: Set vars
id: vars
run: |
git config user.name 'Update-a-Bot'
git config user.email 'insights@github.com'
echo "upstream_schema_latest_sha=$(git ls-remote https://github.com/RedHatInsights/inventory-schemas.git master | cut -c -7)" >> $GITHUB_OUTPUT
echo "system_profile_schema_sha=$(cat inventory-schemas/system_profile_schema_sha.txt)" >> $GITHUB_OUTPUT
- name: update schema file
id: update_schema
run: |
cp inventory-schemas-upstream/schemas/system_profile/v1.yaml inventory-schemas/system_profile_schema.yaml
if [[ "${{ steps.vars.outputs.upstream_schema_latest_sha }}" != "${{steps.vars.outputs.system_profile_schema_sha }}" ]]; then
echo "${{ steps.vars.outputs.upstream_schema_latest_sha }}" > inventory-schemas/system_profile_schema_sha.txt
git diff
echo "update_schema=yes" >> $GITHUB_OUTPUT
else
echo "update_schema=no" >> $GITHUB_OUTPUT
echo "No New Changes in RedHatInsights/inventory-schemas"
fi
- name: update mapping from schema
if: steps.update_schema.outputs.update_schema == 'yes'
run: |
cd scripts
npm ci
npm run updateFromSchema
npm run coverage -- -u
git diff
git add -u
git commit -m "updated xjoin-search to support schema changes. SHA: ${{ steps.vars.outputs.upstream_schema_latest_sha }}" || echo "No new changes"
- name: remove schema submodule
run: rm -r inventory-schemas-upstream
- name: Create Pull Request
if: steps.update_schema.outputs.update_schema == 'yes'
uses: peter-evans/create-pull-request@v5
with:
branch: create_pull_request/update_mapping
delete-branch: true
title: 'chore(update_mapping) Update mapping'
body: |
Updated xjoin-search to support the latest inventory-schemas changes