name: Check for Generated Files on: # Triggers the workflow on push or pull request events but only for the dev branch pull_request: branches: [dev] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: jobs: checkFiles: name: Check Files runs-on: ubuntu-latest steps: - name: Checkout files uses: actions/checkout@v2 - name: Check bundle files id: changed-bundle-files uses: tj-actions/changed-files@v18.4 with: files: | dist/* index.html main.bundle.js main.bundle.js.map - name: Check documentation changes id: changed-markdown-doc-files uses: tj-actions/changed-files@v18.4 with: files: | markdown/*.md - name: Warn when bundle files were changed id: warn-bundles-changed env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | echo "Creating label (if it does not exist)" LABEL="validation: bundle files modified" gh --repo "${{ github.repository }}" \ label create "$LABEL" --description "Modifications to this pull request are suggested" --color D93F0B || true if [ "${{ steps.changed-bundle-files.outputs.any_changed }}" == "false" ]; then echo "No forbidden files included, removing warning" gh --repo "${{ github.repository }}" \ pr edit "${{ github.event.number }}" --remove-label "$LABEL" || true else echo "Forbidden files included, generating warning" touch comment.txt echo "## Generated build or documentation files were included. PRs should not normally contain any generated files." >> comment.txt echo "" >> comment.txt echo "Review the changes and ensure that including built files was necessary." >> comment.txt echo "Add pr label" gh --repo "${{ github.repository }}" \ pr edit "${{ github.event.number }}" --add-label "$LABEL" echo "And comment on the pr" gh --repo "${{ github.repository }}" \ pr comment "${{ github.event.number }}" --body-file comment.txt fi