Mirror #713
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: Mirror | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| pull_request: | |
| schedule: | |
| - cron: "30 8 * * *" | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Mirror | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: π Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 # zizmor: ignore[artipacked] | |
| - name: π§ Configure git | |
| run: | | |
| git config --global user.name 'Github Actions' | |
| git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
| - name: π¦ Install uv | |
| uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 | |
| with: | |
| version: "latest" | |
| enable-cache: "false" | |
| - name: πͺ Run pre-commit-mirror-maker | |
| run: >- | |
| uvx -p 3.14 --from pre-commit-mirror-maker pre-commit-mirror . --language=python --package-name=pyproject-fmt | |
| --files-regex '(^|/)pyproject\.toml$' | |
| - name: π Update README with current version | |
| run: | | |
| VERSION=$(cat .version) | |
| sed -i "s/rev: \".*\"/rev: \"v$VERSION\"/" README.md | |
| - name: π Format generated files | |
| run: uvx prek run --all-files || true | |
| - name: π Commit fixes and update tag | |
| id: commit | |
| run: | | |
| git add -A | |
| if ! git diff --cached --quiet; then | |
| VERSION=$(cat .version) | |
| git commit -m "Mirror: $VERSION" | |
| git tag -f "v$VERSION" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: π Push changes | |
| if: github.ref == 'refs/heads/main' && steps.commit.outputs.version | |
| run: | | |
| git push origin HEAD:refs/heads/main | |
| git push origin --tags -f | |
| - name: π Create GitHub release | |
| if: github.ref == 'refs/heads/main' && steps.commit.outputs.version | |
| run: gh release create "v${STEPS_COMMIT_OUTPUTS_VERSION}" --generate-notes | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| STEPS_COMMIT_OUTPUTS_VERSION: ${{ steps.commit.outputs.version }} |