Skip to content

GH Actions: safeguard the PR label workflow some more #89

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

Merged
merged 1 commit into from
Nov 11, 2023

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Nov 11, 2023

Description

The srvaroa/labeler action runner will use the labeler.yml from the repo's default branch by default, which is good from a security perspective, but that means that PRs changing the labeler.yml file will not be tested until they have been merged and a next PR is opened.

As the srvaroa/labeler action runner will silently fail, this also means that the labeling will stop working without any indication (other than labels no longer being added).

I'd like to prevent getting into that situation (again). The yamllint workflow I introduced earlier is already a big step in the right direction.

This commit introduces a second safeguard:

  • It adds a second job to the workflow which will only run when the files relevant for the workflow are being changed in a PR.
  • In that case, this second job will: - run with the PR-local version of the labeler.yml file; - run on all pull request events (except merge), not only when the PR is opened. - fail the workflow run if any errors are encountered.

This should make sure that this workflow is safeguarded properly and will continuing functioning as intended, even when changes are made to the logic.

Suggested changelog entry

N/A

Related issues/external references

@jrfnl jrfnl added this to the 3.8.0 milestone Nov 11, 2023
@jrfnl jrfnl force-pushed the feature/ghactions-safeguard-labeler-more branch from 0944e52 to c168993 Compare November 11, 2023 13:19
The `srvaroa/labeler` action runner will use the `labeler.yml` from the repo's default branch by default, which is good from a security perspective, but that means that PRs changing the `labeler.yml` file will not be tested until they have been merged and a _next_ PR is opened.

As the `srvaroa/labeler` action runner will silently fail, this also means that the labeling will stop working without any indication (other than labels no longer being added).

I'd like to prevent getting into that situation (again). The `yamllint` workflow I introduced earlier is already a big step in the right direction.

This commit introduces a second safeguard:
* It adds a second job to the workflow which will only run when the files relevant for the workflow are being changed in a PR.
* In that case, this second job will:
    - run with the PR-local version of the `labeler.yml` file;
    - run on **_all_** pull request events (except merge), not only when the PR is opened.
    - fail the workflow run if any errors are encountered.

This should make sure that this workflow is safeguarded properly and will continuing functioning as intended, even when changes are made to the logic.

Refs:
* srvaroa/labeler#105
@jrfnl jrfnl force-pushed the feature/ghactions-safeguard-labeler-more branch 2 times, most recently from 5f3580f to c7f23e2 Compare November 11, 2023 13:32
@jrfnl
Copy link
Member Author

jrfnl commented Nov 11, 2023

Tested by deliberately introducing a yaml error in the labeler.yml and making sure the correct job in the workflow runs and fails and fails the PR too.
After testing, the introduced error has (of course) been reverted.

@jrfnl jrfnl enabled auto-merge November 11, 2023 13:32
@jrfnl jrfnl merged commit 5ef2b66 into master Nov 11, 2023
@jrfnl jrfnl deleted the feature/ghactions-safeguard-labeler-more branch November 11, 2023 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant