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

Support for Github concurrency to stop obsolete builds #143

Closed
pviolette3 opened this issue Sep 27, 2023 · 3 comments
Closed

Support for Github concurrency to stop obsolete builds #143

pviolette3 opened this issue Sep 27, 2023 · 3 comments

Comments

@pviolette3
Copy link

pviolette3 commented Sep 27, 2023

One key feature of Github Actions is the ability to kill obsolete builds when an update to a PR is pushed, through concurrency control (https://docs.github.com/en/actions/using-jobs/using-concurrency#overview).

I believe the way this Action works is (per docs):

  1. Github starts aws-codebuild-run-build action based on some event (e.g. PR created/updated/edited)
  2. aws-codebuild-run-build action starts codebuild
  3. aws-codebuild-run-build action polls codebuild for status
  4. aws-codebuild-run-build action succeeds or fails based on the final status

I was curious how to accomplish canceling the codebuild job started in (2) if during the polling step (3), the Github action is cancelled.
Would it be possible to use the expression functionality, to stop the aws-codebuild-run-build-action's aws-build-id when the cancellation happens, for example?

Curious if anyone in the community has gotten something like this to work, or if there are any contributions that would be needed to the action to allow this type of thing to work?

Related issue: #134 (comment)

(edit: Action State seems relevant. step (2) could store the build ID in Action State (which can potentially be removed in step (4) upon completion). Then, we can add a cleanup step after main that stops the build if the active build ID is present in the Action State.)

@pbrisbin
Copy link
Contributor

FYI: I've opened #149 with our solution. We install a signal handler for SIGINT that stops the build. GitHub sends this signal when it cancels workflows for whatever reason.

At first, I tried addressing #145 and then doing an if: ${{ cancelled() }}; run: aws codebuild stop-build ..., but even if this action sets the build-id early, it looks like GitHub doesn't allow you to access the outputs of a failed step anyway. In any event, I could not make that approach work.

@taoyong-ty
Copy link
Contributor

I've merged @pbrisbin change. Resolving.

@pviolette3
Copy link
Author

Thank you for adding this feature @pbrisbin @taoyong-ty :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants