-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
half-baked DYI solution for separate action to check for duplicated b…
…uilds
- Loading branch information
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: check for successful workflow runs for the same commit | ||
description: uses the GitHub REST API to check whether a successful workflow run for the same commit already exists | ||
|
||
inputs: | ||
githubToken: | ||
description: "github token" | ||
required: true | ||
# TODO this also needs the id/name of the actual workflow | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: list successful builds | ||
id: list_successful_builds | ||
uses: octokit/[email protected] | ||
with: | ||
# https://docs.github.com/en/rest/actions/workflow-runs | ||
route: GET /repos/${{ github.repository }}/actions/runs?head_sha=${{ github.sha }}&status=success | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.githubToken }} | ||
|
||
# TODO remove this debug output | ||
- run: "echo successful builds: '${{ steps.list_successful_builds.outputs.data }}'" | ||
|
||
- name: process Github API response | ||
id: successful_builds_for_same_commit_exist | ||
run: | | ||
export number_of_successful_builds=${{ fromJson(steps.list_successful_builds.outputs.data).total_count }} | ||
if [[ $number_of_successful_builds -gt 0 ]]; then | ||
echo "result=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "result=false" >> $GITHUB_OUTPUT | ||
fi | ||
# TODO remove this debug output | ||
- run: "echo has successful builds: '${{ steps.successful_builds_for_same_commit_exist.outputs.result }}'" | ||
|
||
# TODO write to output | ||
|
||
outputs: | ||
successful-build-exists: | ||
description: "whether a successful workflow run exists for the same commit" | ||
value: ${{ steps.successful_builds_for_same_commit_exist.outputs.result }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters