From 2675fa394169ff727f200b17f093884bb4ee40ca Mon Sep 17 00:00:00 2001 From: shadcn Date: Wed, 15 Oct 2025 11:04:30 +0400 Subject: [PATCH] ci: add deprecated action (#8465) * ci: add deprecated action * ci: add label * Potential fix for code scanning alert no. 12: Workflow does not contain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .github/workflows/deprecated.yml | 74 ++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/deprecated.yml diff --git a/.github/workflows/deprecated.yml b/.github/workflows/deprecated.yml new file mode 100644 index 000000000..94a26799b --- /dev/null +++ b/.github/workflows/deprecated.yml @@ -0,0 +1,74 @@ +name: Deprecated + +on: + pull_request: + types: [opened, synchronize] + +permissions: + issues: write + contents: read +jobs: + deprecated: + runs-on: ubuntu-latest + steps: + - name: Checkout PR + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v44 + with: + files: | + apps/www/** + files_ignore: | + apps/www/public/r/** + base_sha: ${{ github.event.pull_request.base.sha }} + sha: ${{ github.event.pull_request.head.sha }} + + - name: Comment on PR if www files changed + if: steps.changed-files.outputs.any_changed == 'true' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const changedFiles = `${{ steps.changed-files.outputs.all_changed_files }}`.split(' '); + const wwwFiles = changedFiles.filter(file => + file.startsWith('apps/www/') && + !file.startsWith('apps/www/public/r/') + ); + + if (wwwFiles.length > 0) { + const comment = `Looks like this PR modifies files in \`apps/www\`, which is deprecated. + + Consider applying the change to \`apps/v4\` if relevant.`; + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: comment + }); + + // Add deprecated label + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: ['deprecated'] + }); + } else { + // Remove deprecated label if no www files are changed + try { + await github.rest.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + name: 'deprecated' + }); + } catch (error) { + // Label doesn't exist, which is fine + console.log('Deprecated label not found, skipping removal'); + } + }