Skip to content

Check for Module Updates #10556

Check for Module Updates

Check for Module Updates #10556

# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
name: Check for Module Updates
on:
schedule:
- cron: '17,47 * * * *' # Twice every hour at minute 17 and 47
workflow_dispatch:
inputs:
module:
description: 'Optional specific module to update (e.g. score_communication). If not set, all auto-update modules are checked instead.'
required: false
default: ''
push:
branches:
- main
jobs:
check-updates:
if: ${{ github.event.repository.fork == false }}
runs-on: ubuntu-latest
# permissions must be set even when using a PAT
permissions:
contents: write
pull-requests: write
steps:
- name: 🛡️ Harden Runner
if: github.repository_owner == 'eclipse-score'
uses: step-security/harden-runner@v2.21.1
with:
egress-policy: audit
- name: 📥 Check out
uses: actions/checkout@v7
with:
ref: main
persist-credentials: false # We will use a PAT instead
- name: 🕵️‍♂️ Debug PAT
if: runner.debug
run: |
echo "SCORE_BOT_CLASSIC_PAT is set: [${{ secrets.SCORE_BOT_CLASSIC_PAT != '' }}]"
echo "GITHUB_TOKEN is set: [${{ secrets.GITHUB_TOKEN != '' }}]"
env:
SCORE_BOT_CLASSIC_PAT: ${{ secrets.SCORE_BOT_CLASSIC_PAT }}
- name: "🕵️‍♂️ Debug PAT: /user"
if: runner.debug
run: |
curl -s -H "Authorization: token $SCORE_BOT_CLASSIC_PAT" https://api.github.com/user
env:
SCORE_BOT_CLASSIC_PAT: ${{ secrets.SCORE_BOT_CLASSIC_PAT }}
- name: "🕵️‍♂️ Debug PAT: /repos/eclipse-score/bazel_registry"
if: runner.debug
run: |
curl -s -H "Authorization: token $SCORE_BOT_CLASSIC_PAT" https://api.github.com/repos/eclipse-score/bazel_registry
env:
SCORE_BOT_CLASSIC_PAT: ${{ secrets.SCORE_BOT_CLASSIC_PAT }}
- name: "🕵️‍♂️ Debug PAT: /user/repos"
if: runner.debug
run: |
curl -s -H "Authorization: token $SCORE_BOT_CLASSIC_PAT" https://api.github.com/user/repos?per_page=100
env:
SCORE_BOT_CLASSIC_PAT: ${{ secrets.SCORE_BOT_CLASSIC_PAT }}
- name: ⚙️ Setup uv
uses: astral-sh/setup-uv@v7
- name: 🛠️ Setup Python Dependencies
run: uv sync --dev
- name: 🧩 Run update script
id: registry_manager
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -eu
uv run registry-manager --format github_output ${{ github.event.inputs.module }} >> "$GITHUB_OUTPUT"
- name: 📤 Commit and push to main
id: push_to_main
if: steps.registry_manager.outputs.has_updates == 'true'
continue-on-error: true
env:
SCORE_BOT_CLASSIC_PAT: ${{ secrets.SCORE_BOT_CLASSIC_PAT }}
run: |
set -eu
git config user.name "eclipse-score-bot"
git config user.email "187756813+eclipse-score-bot@users.noreply.github.com"
git add -A
cat <<'EOF' > /tmp/commit_msg.txt
${{ steps.registry_manager.outputs.commit_msg }}
EOF
git commit -F /tmp/commit_msg.txt
git push "https://x-access-token:${SCORE_BOT_CLASSIC_PAT}@github.com/${{ github.repository }}.git" HEAD:main
- name: 📤 Create Pull Request fallback
if: steps.registry_manager.outputs.has_updates == 'true' && steps.push_to_main.outcome == 'failure'
uses: peter-evans/create-pull-request@v8
with:
title: ${{ steps.registry_manager.outputs.pr_title }}
author: eclipse-score-bot <187756813+eclipse-score-bot@users.noreply.github.com>
body: ${{ steps.registry_manager.outputs.pr_body }}
commit-message: ${{ steps.registry_manager.outputs.commit_msg }}
base: main
branch: bot/modules-update
token: ${{ secrets.SCORE_BOT_CLASSIC_PAT }} # PAT belongs to eclipse-score-bot
labels: automation