From a111ecfa77424b8c3a611eb1b48ed930892d35df Mon Sep 17 00:00:00 2001 From: Vicente Canales Date: Sat, 27 Apr 2024 18:18:25 -0400 Subject: [PATCH] split workflow; checkout create-preview-links from trunk --- .github/workflows/preview-theme.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/preview-theme.yml b/.github/workflows/preview-theme.yml index fc35b2d1ce..9a9634d41c 100644 --- a/.github/workflows/preview-theme.yml +++ b/.github/workflows/preview-theme.yml @@ -3,6 +3,8 @@ name: Preview Theme Changes on: pull_request_target: types: [opened, synchronize] +permissions: + pull-requests: write jobs: check-for-changes-to-themes: @@ -43,10 +45,21 @@ jobs: echo "HAS_THEME_CHANGES=true" >> $GITHUB_OUTPUT echo "CHANGED_THEMES=$(echo ${unique_dirs[@]})" >> $GITHUB_ENV echo "Theme directories with changes: $CHANGED_THEMES" + + handle-pr-comment: + runs-on: ubuntu-latest + needs: check-for-changes-to-themes + steps: + - name: Checkout create-preview-links script from trunk + uses: actions/checkout@v2 + with: + repository: Automattic/themes + path: .github/scripts + ref: trunk - name: Add Preview Links comment id: comment-on-pr - if: ${{ steps.check-for-changes.outputs.HAS_THEME_CHANGES == 'true' }} + if: ${{ needs.check-for-changes-to-themes.outputs.HAS_THEME_CHANGES == 'true' }} uses: actions/github-script@v7 with: github-token: ${{ secrets.GITHUB_TOKEN }} @@ -55,7 +68,7 @@ jobs: createPreviewLinks(github, context, process.env.CHANGED_THEMES); - name: Remove comment if no changes are detected - if: ${{ steps.check-for-changes.outputs.HAS_THEME_CHANGES == 'false' }} + if: ${{ needs.check-for-changes-to-themes.outputs.HAS_THEME_CHANGES == 'false' }} uses: actions/github-script@v7 with: github-token: ${{ secrets.GITHUB_TOKEN }} @@ -75,4 +88,4 @@ jobs: repo: context.repo.repo }); } - \ No newline at end of file + \ No newline at end of file