Skip to content

[FB] Rename Dry Beans as Dry Legumes #62

[FB] Rename Dry Beans as Dry Legumes

[FB] Rename Dry Beans as Dry Legumes #62

name: Generate and commit taxonomy mapping changes to requested PR
on:
issue_comment:
types: [created]
concurrency:
group: "generate_mappings"
cancel-in-progress: false
jobs:
generate_missing_mappings:
if: |
contains('["OWNER", "CONTRIBUTOR", "COLLABORATOR", "MEMBER"]', github.event.comment.author_association) &&
github.event.issue.pull_request &&
github.event.comment.body == '/generate_mappings'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
# Checkout only the changed data files
- uses: actions/checkout@v4
- name: Checkout PR
run: gh pr checkout ${{ github.event.issue.number }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Keep only data/*.yml files
run: |
git fetch origin main:main
git reset --hard origin/main
git checkout HEAD@{1} -- 'data/**/*.yml'
# Setup dependencies
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Set up Podman
run: |
sudo apt-get update
sudo apt-get -y install podman
- name: Launch Qdrant server
run: |
port=6333
podman run -d -p ${port}:${port} qdrant/qdrant
echo "Waiting for Qdrant server to be ready..."
sleep 25
- uses: cue-lang/setup-cue@v1.0.0
with:
version: 'v0.7.0'
- name: Install b3sum
run: |
curl -L https://github.com/BLAKE3-team/BLAKE3/releases/download/1.5.3/b3sum_linux_x64_bin -o b3sum
chmod +x b3sum
sudo mv b3sum /usr/local/bin/
- name: Seed database
run: make --file=Makefile seed
- name: Generate missing mappings
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_API_BASE: ${{ secrets.OPENAI_API_BASE }}
run: |
make --file=Makefile generate_mappings
- name: Clean cache and re-generate mapping distribution files
run: |
make --file=Makefile clean
VERBOSE=1 make --file=Makefile build
- name: Create distribution manifest
run: |
target="dist"
manifest="manifest.b3"
manifest_sig="${manifest}.sig"
find "$target" -type f -print0 | sort -z | xargs -0 b3sum > "$manifest"
echo -n "${{ secrets.MANIFEST_KEY }}" | b3sum --keyed "$manifest" > "$manifest_sig"
- uses: actions/upload-artifact@v4
with:
name: generated-mappings
path: |
dist/*/integrations
data/integrations
tmp/mappings_with_low_confidence.txt
manifest.b3
manifest.b3.sig
commit_changes:
runs-on: ubuntu-latest
needs: generate_missing_mappings
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Checkout PR
run: gh pr checkout ${{ github.event.issue.number }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Verify and apply distribution files
- uses: actions/download-artifact@v4
with:
name: generated-mappings
path: .
- name: Install b3sum
run: |
curl -L https://github.com/BLAKE3-team/BLAKE3/releases/download/1.5.3/b3sum_linux_x64_bin -o b3sum
chmod +x b3sum
sudo mv b3sum /usr/local/bin/
- name: Verify file integrity
run: |
manifest="manifest.b3"
manifest_sig="${manifest}.sig"
verify_sig="verify.b3.sig"
echo -n "${{ secrets.MANIFEST_KEY }}" | b3sum --keyed "$manifest" > "$verify_sig"
echo "Vetting $manifest_sig with generated $verify_sig"
if ! (cmp -s "$manifest_sig" "$verify_sig"); then
echo "Error: Integrity failure. Invalid key used to generate ${verify_sig}."
exit 1
fi
rm -f "$manifest_sig" "$verify_sig"
echo "Vetting $manifest"
if ! (b3sum --check "$manifest"); then
echo "Error: Integrity failure. Files are inconsistent with ${manifest}."
exit 1
fi
rm -f "$manifest"
- name: Commit mapping changes
id: commit_changes
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add dist/*/integrations
git add data/integrations
commit_output=$(git commit -m "🤖 Update missing mappings" || echo "No changes to commit")
echo "$commit_output"
echo "commit_message<<EOF" >> $GITHUB_ENV
echo "$commit_output" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
git push || echo "No changes to push"
- name: Read disagree mapping entries
id: read_content
run: |
if [ -f tmp/mappings_with_low_confidence.txt ]; then
low_confidence_mappings=$(cat tmp/mappings_with_low_confidence.txt)
else
low_confidence_mappings="All generated mappings are high confidence."
fi
echo "low_confidence_mappings<<EOF" >> $GITHUB_ENV
echo "$low_confidence_mappings" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Add mapping grading comment to PR
if: env.commit_message != 'No changes to commit'
uses: actions/github-script@v6
with:
script: |
const body = process.env.low_confidence_mappings;
github.rest.issues.createComment({
issue_number: ${{ github.event.issue.number }},
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})