Figure out path nonsense with gha pt 4 #2
Workflow file for this run
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
| on: | ||
| workflow_call: | ||
| inputs: | ||
| TIMEOUT: | ||
| type: number | ||
| default: 10 | ||
| description: "Timeout for the job in minutes" | ||
| jobs: | ||
| fprettify: | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: ${{ inputs.TIMEOUT }} | ||
| env: | ||
| ORG_DOTGITHUB_DIR: ${{ runner.temp }}/org-dotgithub | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.11" | ||
| - name: Install fprettify | ||
| run: pip install fprettify==0.3.7 | ||
| - name: Resolve org config ref | ||
| run: | | ||
| workflow_ref="${{ github.workflow_ref }}" | ||
| if [[ -n "$workflow_ref" && "$workflow_ref" == *"@"* ]]; then | ||
| org_repo_ref="${workflow_ref%@*}" | ||
| org_ref="${workflow_ref#*@}" | ||
| # workflow_ref is owner/repo/.github/workflows/file@ref | ||
| org_repo="${org_repo_ref%%/.github/workflows/*}" | ||
| else | ||
| org_repo="scritical/.github" | ||
| org_ref="main" | ||
| fi | ||
| echo "ORG_REPO=$org_repo" >> "$GITHUB_ENV" | ||
| echo "ORG_REF=$org_ref" >> "$GITHUB_ENV" | ||
| - name: Checkout org-wide configs | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| repository: ${{ env.ORG_REPO }} | ||
| ref: ${{ env.ORG_REF }} | ||
| path: ${{ env.ORG_DOTGITHUB_DIR }} | ||
| fetch-depth: 1 | ||
| - name: Run fprettify script | ||
| run: | | ||
| SCRIPT_PATH="$ORG_DOTGITHUB_DIR/fprettify.sh" | ||
| if [[ ! -f ".fprettify.rc" && -f "$ORG_DOTGITHUB_DIR/.fprettify.rc" ]]; then | ||
| cp "$ORG_DOTGITHUB_DIR/.fprettify.rc" .fprettify.rc | ||
| fi | ||
| if [[ ! -f "$SCRIPT_PATH" ]]; then | ||
| echo "fprettify.sh not found at $SCRIPT_PATH" | ||
| exit 1 | ||
| fi | ||
| bash "$SCRIPT_PATH" | ||
| - name: Check for changes | ||
| run: | | ||
| git diff --summary --exit-code || (echo "fprettify produced changes. Please format and commit." && exit 1) | ||