bitburner-src/.github/workflows/check-for-generated-files.yml
omuretsu 6459b1ab48 Change tests
* Try to fix check for generated files to create a comment on a PR.
* Check for generated files does not count as a failure.
* Lint doesn't fail based on stuff in dist. Prettier and lint no longer use the "diff" version.
* Removed some commands that weren't really used (specific version electron packager commands that require you to have already ran npm run electron to generate .package folder)
2023-02-04 07:42:35 -05:00

65 lines
2.2 KiB
YAML

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