Update Instance Metadata #41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Instance Metadata | |
| on: | |
| schedule: | |
| - cron: '0 0 * * MON' # Runs at 00:00 UTC every Monday | |
| workflow_dispatch: # Allows manual trigger | |
| jobs: | |
| update-metadata: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Install poetry | |
| uses: abatilo/actions-poetry@v2 | |
| - name: Install dependencies | |
| run: | | |
| make install | |
| - name: Generate new metadata | |
| run: | | |
| echo "Running metadata generation..." | |
| poetry run python scripts/generate_instance_metadata.py | |
| echo "Metadata generation completed" | |
| - name: Check for changes | |
| id: check_changes | |
| run: | | |
| git add spot_optimizer/resources/instance_metadata.json | |
| if git diff --cached --quiet; then | |
| echo "No changes detected in metadata file" | |
| echo "changes=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Changes detected in metadata file" | |
| echo "changes=true" >> $GITHUB_OUTPUT | |
| git diff --cached --stat | |
| fi | |
| - name: Configure Git | |
| if: steps.check_changes.outputs.changes == 'true' | |
| run: | | |
| git config user.name 'github-actions[bot]' | |
| git config user.email 'github-actions[bot]@users.noreply.github.com' | |
| - name: Bump version | |
| if: steps.check_changes.outputs.changes == 'true' | |
| run: | | |
| # Get current version from pyproject.toml | |
| CURRENT_VERSION=$(poetry version -s) | |
| echo "Current version: $CURRENT_VERSION" | |
| # Bump patch version (not minor for metadata updates) | |
| poetry version patch | |
| # Get new version | |
| NEW_VERSION=$(poetry version -s) | |
| echo "New version: $NEW_VERSION" | |
| echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
| - name: Commit changes | |
| if: steps.check_changes.outputs.changes == 'true' | |
| run: | | |
| git add spot_optimizer/resources/instance_metadata.json pyproject.toml poetry.lock | |
| git commit -m "chore: update instance metadata and bump version to ${{ env.NEW_VERSION }}" | |
| - name: Create and push tag | |
| if: steps.check_changes.outputs.changes == 'true' | |
| run: | | |
| git tag "v${{ env.NEW_VERSION }}" | |
| git push origin main | |
| git push origin "v${{ env.NEW_VERSION }}" | |
| - name: Trigger publish workflow | |
| if: steps.check_changes.outputs.changes == 'true' | |
| uses: peter-evans/repository-dispatch@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| event-type: publish-trigger | |
| client-payload: '{"version": "${{ env.NEW_VERSION }}"}' | |
| - name: Output summary | |
| if: steps.check_changes.outputs.changes == 'true' | |
| run: | | |
| echo "✅ Metadata update committed and tagged successfully" | |
| echo "Version bumped to: ${{ env.NEW_VERSION }}" | |
| echo "Tag v${{ env.NEW_VERSION }} pushed - this will trigger the publish workflow" | |
| - name: No changes summary | |
| if: steps.check_changes.outputs.changes == 'false' | |
| run: | | |
| echo "ℹ️ No changes detected in instance metadata" | |
| echo "Skipping version bump and PR creation" |