forked from ampproject/amp-wp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ampproject#7649 from ampproject/enhancement/workflows
Update `Build, test & measure` workflow
- Loading branch information
Showing
26 changed files
with
445 additions
and
38,168 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Determine count of changed files | ||
|
||
description: Determine count of changed files based on the current branch and the base branch | ||
|
||
outputs: | ||
count: | ||
description: The count of changed files | ||
value: ${{ steps.determine-file-counts.outputs.count }} | ||
php-count: | ||
description: The count of changed PHP files | ||
value: ${{ steps.determine-file-counts.outputs.php-count }} | ||
css-count: | ||
description: The count of changed CSS files | ||
value: ${{ steps.determine-file-counts.outputs.css-count }} | ||
js-count: | ||
description: The count of changed JS files | ||
value: ${{ steps.determine-file-counts.outputs.js-count }} | ||
gha-workflow-count: | ||
description: The count of changed GHA workflow files | ||
value: ${{ steps.determine-file-counts.outputs.gha-workflow-count }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Fetch base branch | ||
# Only fetch base ref if it's a PR. | ||
if: ${{ github.base_ref != null }} | ||
shell: bash | ||
run: git fetch --depth=1 --no-tags origin ${{ github.base_ref }} | ||
|
||
- name: Determine modified files for PR | ||
if: ${{ github.base_ref != null }} | ||
shell: bash | ||
run: echo "MODIFIED_FILES=$(git diff --name-only FETCH_HEAD HEAD | base64 -w 0)" >> $GITHUB_ENV | ||
|
||
- name: Determine modified files for commit | ||
if: ${{ github.base_ref == null }} | ||
shell: bash | ||
run: echo "MODIFIED_FILES=$(git diff --name-only HEAD~1 HEAD | base64 -w 0)" >> $GITHUB_ENV | ||
|
||
- name: Determine if modified files should make the workflow run continue | ||
id: determine-file-counts | ||
shell: bash | ||
run: | | ||
# Get modified files. | ||
MODIFIED_FILES=$(echo "$MODIFIED_FILES" | base64 -d) | ||
# Determine file counts. | ||
FILE_COUNT=$(php -f ./.github/actions/determine-changed-files/determine-modified-files-count.php "$IGNORE_PATH_REGEX" "$MODIFIED_FILES" --invert) | ||
PHP_FILE_COUNT=$(php -f ./.github/actions/determine-changed-files/determine-modified-files-count.php ".+\.php|composer\.(json|lock)|phpstan\.neon\.dist" "$MODIFIED_FILES") | ||
CSS_FILE_COUNT=$(php -f ./.github/actions/determine-changed-files/determine-modified-files-count.php ".+\.s?css|package\.json|package-lock\.json" "$MODIFIED_FILES") | ||
JS_FILE_COUNT=$(php -f ./.github/actions/determine-changed-files/determine-modified-files-count.php ".+\.(js|snap)|package\.json|package-lock\.json" "$MODIFIED_FILES") | ||
GHA_WORKFLOW_COUNT=$(php -f ./.github/actions/determine-changed-files/determine-modified-files-count.php "(\.github\/workflows\/.+\.yml)" "$MODIFIED_FILES") | ||
# Set output variables. | ||
echo "count=$FILE_COUNT" >> $GITHUB_OUTPUT | ||
echo "php-count=$PHP_FILE_COUNT" >> $GITHUB_OUTPUT | ||
echo "css-count=$CSS_FILE_COUNT" >> $GITHUB_OUTPUT | ||
echo "js-count=$JS_FILE_COUNT" >> $GITHUB_OUTPUT | ||
echo "gha-workflow-count=$GHA_WORKFLOW_COUNT" >> $GITHUB_OUTPUT | ||
# Add modified files summary. | ||
echo "# Modified files summary" >> $GITHUB_STEP_SUMMARY | ||
echo "## Modified files" >> $GITHUB_STEP_SUMMARY | ||
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | ||
echo "$MODIFIED_FILES" >> $GITHUB_STEP_SUMMARY | ||
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | ||
echo "## Modified files count" >> $GITHUB_STEP_SUMMARY | ||
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | ||
echo "Total modified files: $FILE_COUNT" >> $GITHUB_STEP_SUMMARY | ||
echo "PHP files: $PHP_FILE_COUNT" >> $GITHUB_STEP_SUMMARY | ||
echo "CSS files: $CSS_FILE_COUNT" >> $GITHUB_STEP_SUMMARY | ||
echo "JS files: $JS_FILE_COUNT" >> $GITHUB_STEP_SUMMARY | ||
echo "GHA workflow files: $GHA_WORKFLOW_COUNT" >> $GITHUB_STEP_SUMMARY | ||
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | ||
env: | ||
# Ignore Paths: | ||
# - .github/ | ||
# - !.github/actions | ||
# - !.github/workflows | ||
# - .github/actions/draft-release/ | ||
# - .wordpress-org/ | ||
# - docs/ | ||
IGNORE_PATH_REGEX: \.github\/(?!actions|workflows)|\.wordpress-org\/|docs\/|\.github\/actions\/draft-release\/ |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.