add pr version of link checker script #7
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
name: Deleted Assets Workflow | |
on: | |
pull_request: | |
branches: [main] | |
env: | |
ARTIFACT_NAME: 'deletedAssetsArtifact' | |
PATHS_TO_CHECK: 'public' | |
jobs: | |
checkIfAssetsWereDeleted: | |
name: Check if assets were deleted | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository to get the workflow scripts | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 https://github.com/actions/checkout/commit/c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | |
- name: Get count of deleted files | |
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 https://github.com/actions/github-script/commit/d7906e4ad0b1822421a7e6a35d5ca353c962f410 | |
id: set-deleted-files-count | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
result-encoding: string | |
script: | | |
const { PATHS_TO_CHECK } = process.env; | |
const paths = PATHS_TO_CHECK.split(','); | |
const { getDeletedFilesFromPR } = require('./.github/workflows/scripts/utilities.js'); | |
return getDeletedFilesFromPR({github, context, paths}); | |
- name: Create artifact containing the PR number and deleted file count | |
env: | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
run: | | |
artifactName="${{ env.ARTIFACT_NAME }}.txt" | |
echo ${{ env.PR_NUMBER }} >> $artifactName | |
echo ${{ steps.set-deleted-files-count.outputs.result }} >> $artifactName | |
- name: Upload the deleted assets file to artifacts | |
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 https://github.com/actions/upload-artifact/commit/0b7f8abb1508181956e8e162db84b466c27e18ce | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: '${{ env.ARTIFACT_NAME }}.txt' | |
retention-days: 1 |