Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup changes/no changes exit codes for build-command #2381

Merged
merged 5 commits into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 17 additions & 29 deletions .github/workflows/build-command.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: build-command
on:
workflow_dispatch:
# checkov:skip=CKV_GHA_7:We are only triggering these workflows by users with write access manually, it is expected.
# Error was:
# The build output cannot be affected by user parameters other than the build entry point and the top-level source location.
# GitHub Actions workflow_dispatch inputs MUST be empty.
# checkov:skip=CKV_GHA_7:We are only triggering these workflows by users with write access manually, it is expected.
# Error was:
# The build output cannot be affected by user parameters other than the build entry point and the top-level source location.
# GitHub Actions workflow_dispatch inputs MUST be empty.
inputs:
repository:
description: 'The repository from which the slash command was dispatched'
description: "The repository from which the slash command was dispatched"
required: true
comment-id:
description: 'The comment-id of the slash command'
description: "The comment-id of the slash command"
required: true
issue-number:
description: 'The issue number in which the slash command was made'
required: true
description: "The issue number in which the slash command was made"
required: true
actor:
description: 'The user who executed the slash command'
required: true
description: "The user who executed the slash command"
required: true
repository_dispatch:
types: [build-command]
jobs:
Expand Down Expand Up @@ -57,12 +57,11 @@ jobs:
uses: actions/[email protected]
with:
# Version range or exact version of Python or PyPy to use, using SemVer's version range syntax. Reads from .python-version if unset.
python-version: 3.11.1 # optional
python-version: 3.11.2 # optional
# Used to specify a package manager for caching in the default directory. Supported values: pip, pipenv, poetry.
cache: pip # optional
- run: pip install -r requirements.dev.txt
- name: Create comment starting build.sh
if: steps.check-changes.outputs.has-changes != '1'
uses: peter-evans/create-or-update-comment@v2
with:
## Use token if we want to use a PAT instead of GITHUB_TOKEN, GITHUB_TOKEN acts as github-actions[bot]
Expand All @@ -74,21 +73,10 @@ jobs:
> Running script `./build.sh`
- name: Run build script
run: ./build.sh
- name: Check if changes were made
id: check-changes
run: |
git diff --quiet && git diff --staged --quiet
HAS_CHANGES=$?
echo "has-changes=$HAS_CHANGES" >> $GITHUB_OUTPUT
echo "$HAS_CHANGES"
# Commit changes to the PR branch
- name: Commit changes to the PR branch
if: steps.check-changes.outputs.has-changes == '1'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git diff --quiet && git diff --staged --quiet || (git commit -am "[build-command] Update generated files")
git push
- uses: stefanzweifel/git-auto-commit-action@v4
id: auto-commit-action
with:
commit_message: "[build-command] Update generated files"
- name: Add reaction
uses: peter-evans/create-or-update-comment@v2
with:
Expand All @@ -99,7 +87,7 @@ jobs:
issue-number: ${{ github.event.inputs.issue-number }}
reaction-type: hooray
- name: Create final comment updated files
if: steps.check-changes.outputs.has-changes == '1'
if: steps.auto-commit-action.outputs.changes_detected == 'true'
uses: peter-evans/create-or-update-comment@v2
with:
## Use token if we want to use a PAT instead of GITHUB_TOKEN, GITHUB_TOKEN acts as github-actions[bot]
Expand All @@ -110,7 +98,7 @@ jobs:
body: |
> Build command workflow completed updating files.
- name: Create final comment no updated files
if: steps.check-changes.outputs.has-changes != '1'
if: steps.auto-commit-action.outputs.changes_detected == 'false'
uses: peter-evans/create-or-update-comment@v2
with:
## Use token if we want to use a PAT instead of GITHUB_TOKEN, GITHUB_TOKEN acts as github-actions[bot]
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/deploy-DEV-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ on:
- .github/CONTRIBUTING.md
- CHANGELOG.md
- README.md
- .github/workflows/slash-command-dispatch.yml
- .github/workflows/help-command.yml
- .github/workflows/build-command.yml
pull_request:
branches-ignore: []
paths-ignore:
- .github/CONTRIBUTING.md
- CHANGELOG.md
- README.md
- .github/workflows/slash-command-dispatch.yml
- .github/workflows/help-command.yml
- .github/workflows/build-command.yml

###############
# Set the Job #
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/deploy-DEV.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ on:
- .github/CONTRIBUTING.md
- CHANGELOG.md
- README.md
- .github/workflows/slash-command-dispatch.yml
- .github/workflows/help-command.yml
- .github/workflows/build-command.yml
pull_request:
branches-ignore: []
paths-ignore:
- .github/CONTRIBUTING.md
- CHANGELOG.md
- README.md
- .github/workflows/slash-command-dispatch.yml
- .github/workflows/help-command.yml
- .github/workflows/build-command.yml

###############
# Set the Job #
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/test-mega-linter-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ on:
- .github/CONTRIBUTING.md
- CHANGELOG.md
- README.md
- .github/workflows/slash-command-dispatch.yml
- .github/workflows/help-command.yml
- .github/workflows/build-command.yml
pull_request:
paths-ignore:
- .github/CONTRIBUTING.md
- CHANGELOG.md
- README.md
- .github/workflows/slash-command-dispatch.yml
- .github/workflows/help-command.yml
- .github/workflows/build-command.yml

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
- Use docker/build-push-action to build docker images and akhilerm/tag-push-action to release by retagging and pushing beta images instead of rebuilding them
- Authenticate to GitHub API during docker build to avoid reaching limits
- Remove apk go package install in images where possible to decrease image sizes, by @echoix in <https://github.com/oxsecurity/megalinter/pull/2318>
- Create a slash PR bot to run `./build.sh` command manually on PRs, by @echoix in <https://github.com/oxsecurity/megalinter/pull/2353>
- Create a slash PR bot to run `./build.sh` command manually on PRs, by @echoix in [#2353](https://github.com/oxsecurity/megalinter/pull/2353) and [#2381](https://github.com/oxsecurity/megalinter/pull/2381)

- Fixes
- Replace deprecated spectral package, by @bdovaz in by @bdovaz in <https://github.com/oxsecurity/megalinter/pull/2340>
Expand Down