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

OSOE-655: Only run Post Pull Request Checks Automation if the current workflow is the most recent one in Lombiq.GitHub.Actions #247

Merged
merged 133 commits into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
27c25b0
Adding latest workflow run check to post-pull-request.yml
Psichorex Jul 26, 2023
07ff5e5
Merge remote-tracking branch 'origin/dev' into issue/OSOE-655
Psichorex Jul 27, 2023
714666e
Removing env.
Psichorex Jul 28, 2023
bae0624
Setting up for a test.
Psichorex Jul 28, 2023
253a6cb
Optimizing script using Github CLI.
Psichorex Jul 28, 2023
1062066
Fix bad revert.
Psichorex Jul 28, 2023
e58e1c8
Fixing the if statement.
Psichorex Jul 28, 2023
bf33471
Adding an input so the function can be optional.
Psichorex Jul 28, 2023
33982f9
Fixing if.
Psichorex Jul 28, 2023
0ce3bb8
Replacing input.
Psichorex Jul 28, 2023
7abf10c
Fixing check value.
Psichorex Jul 28, 2023
1044a66
Removing leftover.
Psichorex Jul 28, 2023
0fc4c9b
Adding type.
Psichorex Jul 28, 2023
95e4ef7
Optimizing job.
Psichorex Jul 28, 2023
827d63c
Fixing output syntax.
Psichorex Jul 28, 2023
5be7efa
Rewriting script.
Psichorex Jul 28, 2023
afa454c
Using Github Token.
Psichorex Jul 28, 2023
fc0413a
Adding checkout.
Psichorex Jul 28, 2023
485bcde
Adding test line.
Psichorex Jul 28, 2023
4b2aff5
Fixing Latest run number.
Psichorex Jul 28, 2023
6660ce8
Testing output.
Psichorex Jul 28, 2023
e07b22b
Fix.
Psichorex Jul 28, 2023
1e7fa53
Fix.
Psichorex Jul 28, 2023
f68aa78
Adjusting number.
Psichorex Jul 28, 2023
215c52d
Checking output.
Psichorex Jul 28, 2023
41927a3
Checking output.
Psichorex Jul 28, 2023
ce83e78
Checking output.
Psichorex Jul 28, 2023
138b90a
Checking output.
Psichorex Jul 28, 2023
096e414
Checking output.
Psichorex Jul 28, 2023
8f5ad30
Checking output.
Psichorex Jul 28, 2023
c848049
Using id.
Psichorex Jul 28, 2023
93d290b
Test.
Psichorex Jul 28, 2023
37e9cd8
Merge branch 'dev' into issue/OSOE-655
Psichorex Jul 28, 2023
010057f
Test.
Psichorex Jul 28, 2023
1b7dc31
Altering script.
Psichorex Jul 28, 2023
448651b
Test.
Psichorex Jul 28, 2023
7871ec7
Trying out JQ.
Psichorex Jul 29, 2023
0992975
Trying out JQ.
Psichorex Jul 29, 2023
751597e
Fix.
Psichorex Jul 29, 2023
512beca
--json flag.
Psichorex Jul 29, 2023
74a08a1
Checking fields.
Psichorex Jul 29, 2023
c879a96
Checking fields.
Psichorex Jul 29, 2023
be119a4
Checking fields.
Psichorex Jul 29, 2023
dd133bc
Fix.
Psichorex Jul 29, 2023
d9e1bae
Removing testing loggers.
Psichorex Jul 29, 2023
964bb4a
Update .github/workflows/post-pull-request-checks-automation.yml
Psichorex Jul 30, 2023
7e4d890
Update .github/workflows/post-pull-request-checks-automation.yml
Psichorex Jul 30, 2023
b3eca49
Removing output.
Psichorex Jul 30, 2023
01ff540
Merge branch 'issue/OSOE-655' of https://github.com/Lombiq/GitHub-Act…
Psichorex Jul 30, 2023
4a11fbb
Testing.
Psichorex Jul 30, 2023
b2504a2
Testing
Psichorex Jul 30, 2023
4a0afee
Testing
Psichorex Jul 30, 2023
3dafca7
Testing
Psichorex Jul 30, 2023
97ddc95
Testing
Psichorex Jul 30, 2023
4ee75a0
Testing
Psichorex Jul 30, 2023
4dc0222
Do we need checkout?
Psichorex Jul 30, 2023
4d8cbef
Adding composite action.
Psichorex Jul 31, 2023
ef5519b
Removing empty line.
Psichorex Jul 31, 2023
d6f9eb0
Adding input.
Psichorex Jul 31, 2023
f14e6f9
Returning boolean.
Psichorex Jul 31, 2023
1a8b697
Fixing name.
Psichorex Jul 31, 2023
4ba49fc
Fix.
Psichorex Jul 31, 2023
bd8801e
Fix.
Psichorex Jul 31, 2023
b0034d6
Fixing folder and workflow.
Psichorex Jul 31, 2023
64fba55
Fixing errors.
Psichorex Jul 31, 2023
bec282f
Folder structure fix.
Psichorex Jul 31, 2023
279a8b4
Naming.
Psichorex Jul 31, 2023
1ee079b
Testing with false.
Psichorex Jul 31, 2023
eec6cf5
It works with false. Revert.
Psichorex Jul 31, 2023
f90b430
Printing output.
Psichorex Jul 31, 2023
6270a24
Testing.
Psichorex Jul 31, 2023
7b99399
Checkout?
Psichorex Jul 31, 2023
d55ed50
Fix output name.
Psichorex Jul 31, 2023
0a7395f
Remove Checkout.
Psichorex Jul 31, 2023
bb4df5d
Optimizing if.
Psichorex Jul 31, 2023
708a87d
Update .github/actions/check-current-workflow-is-latest/action.yml
Psichorex Jul 31, 2023
f991f08
Update .github/actions/check-current-workflow-is-latest/action.yml
Psichorex Jul 31, 2023
60281e7
Update .github/actions/check-current-workflow-is-latest/action.yml
Psichorex Jul 31, 2023
77739cd
Merge remote-tracking branch 'origin/dev' into issue/OSOE-655
Psichorex Aug 14, 2023
2370a28
Trying to access only the current PR.
Psichorex Aug 14, 2023
baf88aa
Temp removal for testing.
Psichorex Aug 14, 2023
9349733
Fix.
Psichorex Aug 14, 2023
22bb284
Fix.
Psichorex Aug 14, 2023
06f8e42
Test
Psichorex Aug 14, 2023
07ccc86
Test
Psichorex Aug 14, 2023
33deb6b
Test
Psichorex Aug 14, 2023
e797b61
Test
Psichorex Aug 14, 2023
7088f23
Test
Psichorex Aug 14, 2023
7d42426
Test
Psichorex Aug 14, 2023
3252159
Shortening.
Psichorex Aug 14, 2023
c1fee61
Test.
Psichorex Aug 14, 2023
bbd584c
Test
Psichorex Aug 14, 2023
a206262
Test
Psichorex Aug 14, 2023
77557dc
Test
Psichorex Aug 14, 2023
119e091
Test
Psichorex Aug 14, 2023
d8c3d5a
Addressing if syntaxes and some comments.
Psichorex Aug 15, 2023
0e5a07d
Test
Psichorex Aug 15, 2023
6c26cc9
This shouldn't run.
Psichorex Aug 15, 2023
ee1e690
Run2
Psichorex Aug 15, 2023
eb8eff6
Testing values.
Psichorex Aug 15, 2023
ba71a00
Test
Psichorex Aug 15, 2023
cf1b928
Test
Psichorex Aug 15, 2023
fbfa281
Test
Psichorex Aug 15, 2023
a66304e
Removing temp texts.
Psichorex Aug 15, 2023
9008e48
Adding description.
Psichorex Aug 15, 2023
c096a6f
Update .github/actions/check-current-workflow-is-latest/action.yml
Psichorex Aug 17, 2023
dc29f02
Update .github/actions/check-current-workflow-is-latest/action.yml
Psichorex Aug 17, 2023
8930aaa
Renaming + temp removing checkout.
Psichorex Aug 17, 2023
992bb8e
Merge branch 'issue/OSOE-655' of https://github.com/Lombiq/GitHub-Act…
Psichorex Aug 17, 2023
67703f3
Adding echo for testing.
Psichorex Aug 17, 2023
22e913a
Adding back checkout.
Psichorex Aug 17, 2023
4c8581f
Fix.
Psichorex Aug 17, 2023
a7f5622
Test.
Psichorex Aug 17, 2023
cf63121
Remove checkout.
Psichorex Aug 17, 2023
25eff63
Testing repo.
Psichorex Aug 17, 2023
b27580f
Testing.
Psichorex Aug 17, 2023
75476a1
Testing.
Psichorex Aug 17, 2023
054025a
Adding repo identifier.
Psichorex Aug 17, 2023
51d8dc6
Removing echo.
Psichorex Aug 17, 2023
a5184bf
More testing.
Psichorex Aug 17, 2023
abee4f2
Removing echos and adding more filter to the query.
Psichorex Aug 17, 2023
d6eec60
Fixing status switch.
Psichorex Aug 17, 2023
c3f0cfd
Test
Psichorex Aug 18, 2023
abfbcdf
Test
Psichorex Aug 18, 2023
69cf385
r to R fix.
Psichorex Aug 18, 2023
c665d81
To string.
Psichorex Aug 18, 2023
7d6b484
Using Splatting.
Psichorex Aug 18, 2023
8320b07
test
Psichorex Aug 18, 2023
f95f6d1
Fix
Psichorex Aug 18, 2023
a6ed50e
Test
Psichorex Aug 18, 2023
2e26bef
Test with splatting.
Psichorex Aug 20, 2023
3ea457f
!= false instead of == true
Psichorex Aug 20, 2023
fca744f
Reverting issue branch references for GHA
Piedone Aug 20, 2023
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
38 changes: 38 additions & 0 deletions .github/actions/check-current-workflow-is-latest/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Check Current Workflow is the Latest Workflow
description: >
Checks whether the current workflow is the most recent workflow for the pull request. Intentionally not documented in
Actions.md since it's only meant for internal use.

inputs:
current-workflow-id:
description: The current workflow run's database id.
required: true
default: ""

outputs:
is-latest:
description: A boolean value indicating whether the current workflow is the most recent one.
value: ${{ steps.check-current-workflow-equals-latest.outputs.is-latest }}

runs:
using: "composite"
steps:
- name: Setup Scripts
shell: pwsh
run: |
(Resolve-Path "${{ github.action_path }}/../../../Scripts").Path >> $Env:GITHUB_PATH

- name: Check Current Workflow Equals Latest
shell: pwsh
id: check-current-workflow-equals-latest
run: |
$listSwitches = @(
'--repo', '${{ github.repository }}'
'--branch', '${{ github.head_ref }}'
'--workflow', '${{ github.workflow }}'
'--limit', '1'
'--json', 'databaseId'
)
$latestWorkflowRunDatabaseId = $(gh run list @listSwitches | ConvertFrom-Json)[0].databaseId
$currentEqualsLatest = ($latestWorkflowRunDatabaseId -eq ${{ inputs.current-workflow-id }})
Set-GitHubOutput 'is-latest' $currentEqualsLatest
18 changes: 18 additions & 0 deletions .github/workflows/post-pull-request-checks-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,28 @@ on:
type: number
default: 1
description: Configuration for the timeout-minutes parameter of the workflow.
run-only-latest-workflow:
type: string
description: Run only if the current workflow is the most recent workflow.
default: true

jobs:
post-pull-request-checks-automation:
name: Post Pull Request Checks Automation
runs-on: ubuntu-22.04
timeout-minutes: ${{ inputs.timeout-minutes }}
Piedone marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Check Further Steps Should Run
if: inputs.run-only-latest-workflow == 'true'
uses: Lombiq/GitHub-Actions/.github/actions/check-current-workflow-is-latest@dev
id: check-steps-should-run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
current-workflow-id: ${{ github.run_id }}

- name: Set Merge Token
if: steps.check-steps-should-run.outputs.is-latest != 'false'
shell: pwsh
env:
MERGE_TOKEN: ${{ secrets.MERGE_TOKEN }}
Expand All @@ -55,13 +70,15 @@ jobs:
"MERGE_TOKEN=$mergeToken" >> $Env:GITHUB_ENV

- name: Automatically Merge Pull Request
if: steps.check-steps-should-run.outputs.is-latest != 'false'
uses: Lombiq/GitHub-Actions/.github/actions/auto-merge-pull-request@dev
env:
GITHUB_TOKEN: ${{ env.MERGE_TOKEN }}
with:
merge-method: ${{ inputs.merge-method }}

- name: Automatically Resolve or Done Jira issue
if: steps.check-steps-should-run.outputs.is-latest != 'false'
uses: Lombiq/GitHub-Actions/.github/actions/auto-resolve-done-jira-issue@dev
env:
GITHUB_TOKEN: ${{ env.MERGE_TOKEN }}
Expand All @@ -70,6 +87,7 @@ jobs:
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}

- name: Remove Label
if: steps.check-steps-should-run.outputs.is-latest != 'false'
# v2.0.0
uses: buildsville/add-remove-label@eeae411a9be2e173f2420e1644514edbecc4e835
with:
Expand Down