Skip to content
16 changes: 16 additions & 0 deletions .github/workflows/add-to-project-board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
##### Aggregate Commerce PRs and Issues into a respective Organizational Project #####

name: Add pull requests and issues to projects

on:
pull_request_target:
types:
- opened
issues:
types:
- opened

jobs:
call-workflow-add-to-project:
uses: AdobeDocs/commerce-php/.github/workflows/add-to-project_job.yml@main
secrets: inherit
23 changes: 23 additions & 0 deletions .github/workflows/add-to-project_job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Add to project job

on:
workflow_call

jobs:
add-to-project:
runs-on: ubuntu-latest

steps:
- name: Add to Commerce PR project
if: github.event_name == 'pull_request_target'
uses: actions/add-to-project@v1.0.2
with:
project-url: https://github.com/orgs/AdobeDocs/projects/5 # The organizational project for pull requests
github-token: ${{ secrets.COMMERCE_PROJECT_AUTOMATION }}

- name: Add to Commerce Issue project
if: github.event_name == 'issues'
uses: actions/add-to-project@v1.0.2
with:
project-url: https://github.com/orgs/AdobeDocs/projects/6 # The organizational project for issues
github-token: ${{ secrets.COMMERCE_PROJECT_AUTOMATION }}
2 changes: 1 addition & 1 deletion .github/workflows/pr-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: PR Comment
on:
workflow_run:
workflows: ["Validate pull request"]
workflows: ["PR validation"]
types:
- completed

Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: PR validation
on:
pull_request:

jobs:
validate:
uses: ./.github/workflows/validate-pr.yml
with:
pr_number: ${{ github.event.pull_request.number }}
base_ref: ${{ github.event.pull_request.base.ref }}

30 changes: 25 additions & 5 deletions .github/workflows/validate-pr.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
---
name: Validate pull request
on:
pull_request:
workflow_call:
inputs:
pr_number:
description: 'Pull request number'
required: true
type: number
base_ref:
description: 'Base branch reference'
required: true
type: string

jobs:
# Check if src/pages files were changed
Expand All @@ -18,8 +27,8 @@ jobs:
- name: Check for src/pages changes
id: filter
run: |
git fetch origin ${{ github.base_ref }}
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
git fetch origin ${{ inputs.base_ref }}
CHANGED_FILES=$(git diff --name-only origin/${{ inputs.base_ref }}...HEAD)
if echo "$CHANGED_FILES" | grep -q "^src/pages/"; then
echo "run_validation=true" >> $GITHUB_OUTPUT
echo "✅ Changes detected in src/pages/"
Expand Down Expand Up @@ -99,7 +108,7 @@ jobs:

# Save warning status for the comment workflow
echo "true" > has-warnings.txt
echo "${{ github.event.pull_request.number }}" > pr-number.txt
echo "${{ inputs.pr_number }}" > pr-number.txt
else
echo "✅ **No issues found!**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
Expand All @@ -108,7 +117,7 @@ jobs:

# Save no-warning status
echo "false" > has-warnings.txt
echo "${{ github.event.pull_request.number }}" > pr-number.txt
echo "${{ inputs.pr_number }}" > pr-number.txt
fi

- name: Upload lint results
Expand All @@ -131,6 +140,8 @@ jobs:
# If no src/pages files changed, pass automatically
if [[ "${{ needs.check-files.outputs.run_validation }}" == "false" ]]; then
echo "✅ No src/pages/ files changed - validation skipped"
echo "false" > has-warnings.txt
echo "${{ inputs.pr_number }}" > pr-number.txt
exit 0
fi

Expand All @@ -147,3 +158,12 @@ jobs:
echo "Remark Lint: ${{ needs.remark-lint.result }}"
exit 1
fi

- name: Upload lint results for skipped validation
if: needs.check-files.outputs.run_validation == 'false'
uses: actions/upload-artifact@v4
with:
name: lint-results
path: |
has-warnings.txt
pr-number.txt