diff --git a/.github/workflows/add-to-project-board.yml b/.github/workflows/add-to-project-board.yml new file mode 100644 index 0000000..ec59fb6 --- /dev/null +++ b/.github/workflows/add-to-project-board.yml @@ -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: ./.github/workflows/add-to-project_job.yml + secrets: inherit diff --git a/.github/workflows/add-to-project_job.yml b/.github/workflows/add-to-project_job.yml new file mode 100644 index 0000000..41719f7 --- /dev/null +++ b/.github/workflows/add-to-project_job.yml @@ -0,0 +1,27 @@ +name: Add to project job + +on: + workflow_call: + secrets: + COMMERCE_PROJECT_AUTOMATION: + description: 'GitHub token for project automation' + required: true + +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 }} diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index 912fb34..ccfed56 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -2,7 +2,7 @@ name: PR Comment on: workflow_run: - workflows: ["Validate pull request"] + workflows: ["PR validation"] types: - completed diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml new file mode 100644 index 0000000..14b9587 --- /dev/null +++ b/.github/workflows/pr-validation.yml @@ -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 }} + diff --git a/.github/workflows/validate-pr.yml b/.github/workflows/validate-pr.yml index a6b515c..d403bc2 100644 --- a/.github/workflows/validate-pr.yml +++ b/.github/workflows/validate-pr.yml @@ -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 @@ -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/" @@ -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 @@ -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 @@ -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 @@ -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