# Example GitHub Actions workflow for updating JDK metadata
# Copy this to .github/workflows/update-metadata.yml to enable
name: Update JDK Metadata
on:
schedule:
# Run weekly on Sunday at midnight UTC
- cron: '0 0 * * 0'
workflow_dispatch:
inputs:
distributions:
description: 'Comma-separated list of distributions (leave empty for all)'
required: false
type: string
platforms:
description: 'Comma-separated list of platforms (leave empty for all)'
required: false
type: string
jobs:
update-metadata:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Cache cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build metadata generator
run: cargo build --release --bin kopi-metadata-gen
- name: Generate metadata
env:
DISTRIBUTIONS: ${{ github.event.inputs.distributions || '' }}
PLATFORMS: ${{ github.event.inputs.platforms || '' }}
run: |
./scripts/generate-metadata.sh \
--output ./metadata-new \
--archive metadata-$(date +%Y-%m).tar.gz
- name: Upload metadata archive
uses: actions/upload-artifact@v4
with:
name: metadata-archive
path: metadata-*.tar.gz
retention-days: 90
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: |
Update JDK metadata from foojay API
Generated on: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
Distributions: ${{ github.event.inputs.distributions || 'all' }}
Platforms: ${{ github.event.inputs.platforms || 'all' }}
title: 'Update JDK metadata'
body: |
## JDK Metadata Update
This PR updates the JDK metadata from the foojay API.
### Generation Details
- **Date**: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
- **Distributions**: ${{ github.event.inputs.distributions || 'all' }}
- **Platforms**: ${{ github.event.inputs.platforms || 'all' }}
### Files Changed
See the Files tab for the complete list of updated metadata files.
### Validation
- [x] Metadata generated successfully
- [x] All files validated
- [x] Archive created
Please review and merge when ready.
branch: update-metadata-${{ github.run_number }}
delete-branch: true
- name: Comment on PR with statistics
if: steps.create-pr.outputs.pull-request-number
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const indexPath = './metadata-new/index.json';
if (fs.existsSync(indexPath)) {
const index = JSON.parse(fs.readFileSync(indexPath, 'utf8'));
const fileCount = index.files.length;
const distributions = [...new Set(index.files.map(f => f.distribution))];
const comment = `### 📊 Metadata Statistics
- **Total files**: ${fileCount}
- **Distributions**: ${distributions.join(', ')}
- **Last updated**: ${index.updated}
`;
github.rest.issues.createComment({
issue_number: ${{ steps.create-pr.outputs.pull-request-number }},
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
}