From a67bc1505a80e72848443f896e96bff02ba31e8e Mon Sep 17 00:00:00 2001 From: Ben Knutson Date: Wed, 18 Feb 2026 16:23:20 +0000 Subject: [PATCH] Refactor Github Action per b/485167538 --- .github/workflows/code-standards.yml | 12 +++++++++--- .github/workflows/doctum.yml | 21 +++++++++++++++------ .github/workflows/static-analysis.yml | 10 +++++++--- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/.github/workflows/code-standards.yml b/.github/workflows/code-standards.yml index 4b5566de..79bb17bb 100644 --- a/.github/workflows/code-standards.yml +++ b/.github/workflows/code-standards.yml @@ -65,12 +65,14 @@ jobs: - name: 'Setup jq' uses: dcarbone/install-jq-action@v2 - name: Install PHP CS Fixer - run: composer global require friendsofphp/php-cs-fixer:${{ inputs.version }} + run: composer global require friendsofphp/php-cs-fixer:${INPUTS_VERSION} + env: + INPUTS_VERSION: ${{ inputs.version }} - name: Run PHP CS Fixer run: | # set environment variables in script - export RULES=$(echo $'${{ inputs.rules }} ${{ inputs.add-rules }}'|tr -d '\n\t\r '|jq -s '.[0] * .[1]' -crM) - export EXCLUDE_PATTERNS=$(echo $'${{ inputs.exclude-patterns }}'|tr -d '\n\t\r ') + export RULES=$(echo $'${INPUTS_RULES} ${INPUTS_ADD_RULES}'|tr -d '\n\t\r '|jq -s '.[0] * .[1]' -crM) + export EXCLUDE_PATTERNS=$(echo $'${INPUTS_EXCLUDE_PATTERNS}'|tr -d '\n\t\r ') # use config path only if EXCLUDE_PATTERN is empty CMD_PATH=$([ "$EXCLUDE_PATTERNS" = "" ] && echo "$CONFIG_PATH" || echo "") @@ -93,3 +95,7 @@ jobs: echo "" exit 1 fi + env: + INPUTS_RULES: ${{ inputs.rules }} + INPUTS_ADD_RULES: ${{ inputs.add-rules }} + INPUTS_EXCLUDE_PATTERNS: ${{ inputs.exclude-patterns }} diff --git a/.github/workflows/doctum.yml b/.github/workflows/doctum.yml index 61a9a323..e0076dba 100644 --- a/.github/workflows/doctum.yml +++ b/.github/workflows/doctum.yml @@ -52,13 +52,13 @@ jobs: use Doctum\Version\GitVersionCollection; use Symfony\Component\Finder\Finder; - $defaultVersion = '${{ inputs.default_version }}'; - $tagPattern = '${{ inputs.tag_pattern }}'; + $defaultVersion = '${INPUTS_DEFAULT_VERSION}'; + $tagPattern = '${INPUTS_TAG_PATTERN}'; $iterator = Finder::create() ->files() ->name('*.php') - ->notName('${{ inputs.exclude_file }}') + ->notName('${INPUTS_EXCLUDE_FILE}') ->exclude('GPBMetadata') ->in(__DIR__ . '/src'); @@ -71,8 +71,8 @@ jobs: } return new Doctum($iterator, [ - 'title' => '${{ inputs.title }}', - 'theme' => '${{ inputs.theme }}', + 'title' => '${INPUTS_TITLE}', + 'theme' => '${INPUTS_THEME}', 'versions' => $versions, 'build_dir' => __DIR__ . '/.build/%version%', 'cache_dir' => __DIR__ . '/.cache/%version%', @@ -84,6 +84,12 @@ jobs: ) echo "$DOCTUM_CONFIG"; # for debugging echo "$DOCTUM_CONFIG" > doctum-config.php; + env: + INPUTS_DEFAULT_VERSION: ${{ inputs.default_version }} + INPUTS_TAG_PATTERN: ${{ inputs.tag_pattern }} + INPUTS_EXCLUDE_FILE: ${{ inputs.exclude_file }} + INPUTS_TITLE: ${{ inputs.title }} + INPUTS_THEME: ${{ inputs.theme }} - name: Run Doctum to Generate Documentation run: | php doctum.phar update doctum-config.php --ignore-parse-errors @@ -95,8 +101,11 @@ jobs: name: Redirect Index to Latest Version run: | cat << EOF > .build/index.html - + EOF + env: + GITHUB_EVENT_REPOSITORY_NAME: ${{ github.event.repository.name }} + INPUTS_DEFAULT_VERSION: ${{ inputs.default_version }} - if: ${{ !inputs.dry_run }} name: Move generated files into GitHub Pages branch run: | diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 201dc30b..cbad84ef 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -28,6 +28,10 @@ jobs: - name: Run Script run: | composer install -q - composer global require phpstan/phpstan:${{ inputs.version }} -q - ~/.composer/vendor/bin/phpstan analyse ${{ inputs.paths }} \ - --autoload-file=${{ inputs.autoload-file }} + composer global require phpstan/phpstan:${INPUTS_VERSION} -q + ~/.composer/vendor/bin/phpstan analyse ${INPUTS_PATHS} \ + --autoload-file=${INPUTS_AUTOLOAD_FILE} + env: + INPUTS_VERSION: ${{ inputs.version }} + INPUTS_PATHS: ${{ inputs.paths }} + INPUTS_AUTOLOAD_FILE: ${{ inputs.autoload-file }}