2022-03-21 18:17:20 +01:00
|
|
|
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
|
2023-02-04 13:42:35 +01:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2022-03-21 18:17:20 +01:00
|
|
|
run: |
|
2023-02-04 13:42:35 +01:00
|
|
|
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
|
2022-03-21 18:17:20 +01:00
|
|
|
|
2023-02-04 13:42:35 +01:00
|
|
|
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
|
2022-03-21 18:17:20 +01:00
|
|
|
else
|
2023-02-04 13:42:35 +01:00
|
|
|
echo "Forbidden files included, generating warning"
|
2022-03-21 18:17:20 +01:00
|
|
|
|
2023-02-04 13:42:35 +01:00
|
|
|
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
|
2022-03-21 18:17:20 +01:00
|
|
|
|
2023-02-04 13:42:35 +01:00
|
|
|
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
|