Update Submodules #34
This file contains 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 Submodules | |
on: | |
push: | |
branches: [ dev ] | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
check_submodules: | |
name: Check Submodules | |
runs-on: ubuntu-latest | |
outputs: | |
has_changes: ${{ steps.check.outputs.has_changes }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Create new branch and push changes | |
run: | | |
git submodule update --remote | |
- name: Check for changes | |
id: check | |
run: | | |
git diff --quiet || echo "::set-output name=has_changes::true" | |
update_submodules: | |
name: Update Submodules | |
runs-on: ubuntu-latest | |
needs: [check_submodules] | |
if: needs.check_submodules.outputs.has_changes == 'true' | |
steps: | |
- name: Setup Python 3.10.4 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.10.4' | |
- name: Setup Poetry | |
uses: abatilo/actions-poetry@v3 | |
with: | |
poetry-version: 1.8.2 | |
- name: Install Dependencies | |
run: | | |
poetry install --no-root | |
- name: Update Submodule | |
run: | | |
datamodel-codegen --input ./compose-spec/schema/compose-spec.json --output-model-type pydantic_v2.BaseModel --field-constraints --output ./compose_viz/spec/compose_spec.py | |
poetry run python ./update-submodules.py | |
- name: Execute pre-commit | |
continue-on-error: true | |
run: | | |
poetry run python -m pre_commit run --all-files | |
- name: Push changes | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git checkout -b $GITHUB_RUN_ID | |
git commit -am "chore: update submodules" | |
git push --set-upstream origin $GITHUB_RUN_ID | |
- name: File PR | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
await github.rest.pulls.create({ | |
owner: '${{ github.repository_owner }}', | |
repo: 'compose-viz', | |
head: process.env.GITHUB_RUN_ID, | |
base: 'main', | |
title: `chore: update submodules (${process.env.GITHUB_RUN_ID})`, | |
body: `Please add the version tag to trigger the release.`, | |
}); |