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

refactor: CI/CD Pipelines #259

Merged
merged 318 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
318 commits
Select commit Hold shift + click to select a range
2e760c5
fix: if conditions
Jan 4, 2024
b009a77
fix: production branch calculation
Jan 4, 2024
0fc137a
fix: release artifact name
Jan 4, 2024
c991efa
fix: release artifact name
Jan 4, 2024
cea08eb
Merge branch 'SAP:main' into main
Johannes-Schneider Jan 8, 2024
aba10b2
feat: create new CI workflow
Jan 8, 2024
eea5bc4
refactor: change parameter descriptions in CI workflow
Jan 8, 2024
4544c4d
refactor: rename some jobs
Jan 8, 2024
c86c788
fix: check formatting is always executed
Jan 8, 2024
4a47a75
refactor: move individual actions into CI pipeline
Jan 9, 2024
b27d092
refactor: repository-version is now a required parameter
Jan 9, 2024
493880e
refactor: repo version parameter in CI pipeline
Jan 9, 2024
abdd1b0
refactor: trigger CI-Build workflow from regular CI job
Jan 9, 2024
54b4846
fix: expose GH_TOKEN env var
Jan 9, 2024
3f81e03
fix: checkout repo in Run CI Build job
Jan 9, 2024
80d2887
fix: workflow invocation
Jan 9, 2024
109443a
feat: add reusable action to trigger a workflow
Jan 9, 2024
d48de2b
fix: parameter list
Jan 9, 2024
833f6da
fix: parameter list
Jan 9, 2024
87445f2
fix: parameter list
Jan 9, 2024
99bae41
fix: typo
Jan 9, 2024
5bdc648
chore: add workflow URL to step summary
Jan 9, 2024
b29c93b
fix: poll run status manually
Jan 9, 2024
7ea6480
chore: slightly change step summary output
Jan 9, 2024
4fe3c48
feat: add workflow ref parameter
Jan 9, 2024
8c0ddaf
chore: update error message
Jan 9, 2024
c64fc23
chore: revert back to using gh run watch
Jan 9, 2024
febc0fa
fix: remove comment block
Jan 9, 2024
999ea48
chore: back to manual polling
Jan 9, 2024
6e798bb
throwaway: print github context
Jan 9, 2024
6885fdd
fix: provide a proper branch name for the workflow ref
Jan 9, 2024
d99573b
throwaway: debug logs
Jan 9, 2024
8650d0d
fix: jq commands
Jan 9, 2024
ff1b5db
fix: determine workflow status
Jan 9, 2024
34cae62
feat: cancel ci build eagerly
Jan 9, 2024
50ec688
feat: consider aborted workflows
Jan 9, 2024
5324531
chore: tiny improvements
Jan 9, 2024
ec37356
chore: remove github context logging
Jan 9, 2024
4552cb5
fix: use correct commit sha for pull requests
Jan 9, 2024
5ab7bc5
refactor: split run workflow action in two parts
Jan 9, 2024
e513bef
fix: remove the waiting part in trigger workflow
Jan 9, 2024
04d9fb9
fix: run id in await workflow
Jan 9, 2024
628be60
feat: add PR status
Jan 9, 2024
9545572
fix: remove github token var
Jan 9, 2024
942f442
feat: report status
Jan 9, 2024
0226a98
fix: try passing sha as string
Jan 9, 2024
fb610cc
fix: use correct parameter name
Jan 9, 2024
6812b08
fix: typo
Jan 9, 2024
e53adb9
fix: typo
Jan 9, 2024
921d32c
chore: print github script output earlier
Jan 10, 2024
35798ce
fix: result logging
Jan 10, 2024
d2fee40
refactor: change to create commit status
Jan 10, 2024
b0d7836
fix: typo
Jan 10, 2024
447d14c
fix: permissions
Jan 10, 2024
1d95e27
feat: report final commit status
Jan 10, 2024
b57e636
fix: final commit status
Jan 10, 2024
adf4355
fix: waiting for the workflow
Jan 10, 2024
b32900d
fix: increase gh watch interval to avoid rate limits
Jan 10, 2024
618c3c3
fix: increase polling intervals to avoid running into rate limits
Jan 10, 2024
2bbb146
fix: commit check status
Jan 10, 2024
4098b54
refactor: separate main-build and pr-build
Jan 10, 2024
363c4e1
chore: minor improvements
Jan 10, 2024
ca3c69c
Merge pull request #13 from Johannes-Schneider/feat/report-status
Johannes-Schneider Jan 10, 2024
9541128
Merge branch 'SAP:main' into main
Johannes-Schneider Jan 10, 2024
87ad04f
refactor: move commit status creation / updating to the await workflo…
Jan 11, 2024
44dc956
fix: add needed permissions for the main build
Jan 11, 2024
0251374
fix: minor left over comments
Jan 11, 2024
4feb237
feat: (WIP) add new workflow to delete stale caches
Jan 11, 2024
fcb9a8b
fix: workflow trigger
Jan 11, 2024
c638386
Merge pull request #14 from Johannes-Schneider/feat/delete-stale-bran…
Johannes-Schneider Jan 11, 2024
0486d6c
refactor: use branch ref instead of pull request ref for ci workflow
Jan 11, 2024
1b8cbc1
Merge branch 'SAP:main' into main
Johannes-Schneider Jan 15, 2024
e65acef
refactor: increase default polling interval and adjust workflow param…
Jan 15, 2024
88aacb0
feat: create re-usable workflow for (PR) builds
Jan 15, 2024
96b9191
chore: remove old PR build workflow
Jan 15, 2024
1bbc488
fix: workflow trigger
Jan 15, 2024
08b4609
fix: quoting in job condition
Jan 15, 2024
00eeb08
fix: bash comparison syntax
Jan 15, 2024
36a50ef
chore: add debug statement to see current github context
Jan 15, 2024
f69580f
chore: add debug statement to see current github context
Jan 15, 2024
d73540c
fix: get correct event name
Jan 15, 2024
f5e808c
fix: restore sdk m2 for code analysis and tests
Jan 15, 2024
7341a2d
fix: download artifacts to correct paths
Jan 15, 2024
1b6ff6b
fix: env vars
Jan 15, 2024
c89604b
fix: archetype working dirs
Jan 15, 2024
322099f
chore: make workflow parameters required
Jan 15, 2024
98b5dd1
fix: provide sha and ref to codeql action
Jan 15, 2024
4ed3306
fix: use correct refs name for codeql
Jan 15, 2024
914f9e4
chore: remove branch parameter as the codeql warning cannot be avoided
Jan 15, 2024
e78f61e
fix: workflow parameter types
Jan 15, 2024
e3bacb3
Merge pull request #16 from Johannes-Schneider/feat/replace-old-workf…
Johannes-Schneider Jan 15, 2024
7297fae
Merge branch 'SAP:main' into main
Johannes-Schneider Jan 16, 2024
faa1cb7
feat: use new continuous-integration workflow in main-build
Jan 16, 2024
2fcf400
fix: trigger workflow invocation
Jan 16, 2024
66c5380
fix: typo in ci workflow
Jan 16, 2024
aa65ab5
Merge branch 'SAP:main' into main
Johannes-Schneider Jan 16, 2024
be947f0
fix: create release artifacts in a different folder
Jan 16, 2024
919aab4
fix: create release artifacts in a different folder
Jan 16, 2024
536ca65
fix: upload release artifacts
Jan 16, 2024
c419666
fix: download release artifacts
Jan 16, 2024
4e20f38
fix: snapshot deployment
Jan 16, 2024
1e373f2
refactor: prepare release workflow
Jan 17, 2024
7a560e6
fix: make branch a mandatory parameter
Jan 17, 2024
d8f280e
fix: path prefix for release artifacts
Jan 17, 2024
e830b24
fix: permissions
Jan 17, 2024
4399607
throwaway: disable black duck scan for testing
Jan 17, 2024
2f14816
fix: upload correct artifacts to release
Jan 17, 2024
fdab7ad
feat: create docs and release notes PRs
Jan 17, 2024
9f71431
Merge branch 'SAP:main' into main
Johannes-Schneider Jan 17, 2024
89a1c96
feat: rollback changes on failure
Jan 17, 2024
1ac4603
fix: typo
Jan 17, 2024
56497a3
throwaway: disable unit tests for faster iterations
Jan 17, 2024
7b68f97
throwaway: disable codeql for faster iterations
Jan 17, 2024
7872bbe
fix: handling failures
Jan 17, 2024
18ef7b3
Merge branch 'SAP:main' into main
Johannes-Schneider Jan 17, 2024
a60246f
fix: root dir of cloud sdk docs
Jan 17, 2024
5c7d579
Merge remote-tracking branch 'origin/main'
Jan 17, 2024
39b3ecb
fix: javadoc replacement
Jan 17, 2024
cea5777
fix: javadoc replacement
Jan 17, 2024
96b5a19
fix: code pr creation
Jan 17, 2024
7ec53c5
throwaway: disable more tests in CI workflow
Jan 17, 2024
98cc1e1
chore: add todos
Jan 17, 2024
3ae6e21
Merge branch 'SAP:main' into main
Johannes-Schneider Jan 17, 2024
79cd298
Added release notes automation
CharlesDuboisSAP Jan 19, 2024
eba050d
fix directory cloud-sdk
CharlesDuboisSAP Jan 19, 2024
fc69dab
Fixed branch name Release Notes
CharlesDuboisSAP Jan 19, 2024
9676df5
Fixed Release Notes PR creation
CharlesDuboisSAP Jan 19, 2024
a0dbdad
PR name fix
CharlesDuboisSAP Jan 19, 2024
37dc952
PR name fix, Code PR 1 try
CharlesDuboisSAP Jan 19, 2024
bbe715b
added PR_URL output
CharlesDuboisSAP Jan 19, 2024
ec98db1
java-release-notes2
CharlesDuboisSAP Jan 19, 2024
6351aa0
cleaned up git push, renamed release notes branch, Fixed PR link, upd…
CharlesDuboisSAP Jan 22, 2024
38b9fd3
Final, ready for PR
CharlesDuboisSAP Jan 22, 2024
b99d1fb
Merge branch 'SAP:main' into main
CharlesDuboisSAP Jan 22, 2024
30cc246
Fix mixup of files
CharlesDuboisSAP Jan 23, 2024
03f0938
Merge branch 'main' into 318-release
CharlesDuboisSAP Jan 23, 2024
48a7fe8
Moved template to scripts directory
CharlesDuboisSAP Jan 23, 2024
93b66d2
Revert fix on perform release
CharlesDuboisSAP Jan 23, 2024
1e7c6d1
Merge branch 'main' into 318-release
CharlesDuboisSAP Jan 23, 2024
2e515d4
Warn when minor version % 15
CharlesDuboisSAP Jan 23, 2024
42fd988
Merge PR
CharlesDuboisSAP Jan 23, 2024
6303e9e
Ready to test
CharlesDuboisSAP Jan 23, 2024
44be1ca
Fix reset release notes
CharlesDuboisSAP Jan 23, 2024
3b09317
Revert revert
CharlesDuboisSAP Jan 23, 2024
becfada
Merge branch 'main' into johannes-main
CharlesDuboisSAP Jan 23, 2024
ecbbcb5
Fix release notes template directory
CharlesDuboisSAP Jan 23, 2024
2d6a793
Perform release first try, triggers by approving and merges all Appro…
CharlesDuboisSAP Jan 24, 2024
6e74b66
Added Publish the Draft Release
CharlesDuboisSAP Jan 24, 2024
892c525
changed branch instantiation
CharlesDuboisSAP Jan 24, 2024
26a1ad1
Renamed branches
CharlesDuboisSAP Jan 24, 2024
50c5b2e
Merge branch 'main' into johannes-main
CharlesDuboisSAP Jan 24, 2024
7ea2aae
Merge main
CharlesDuboisSAP Jan 24, 2024
3ece317
Changed git tag
CharlesDuboisSAP Jan 24, 2024
0dc8fe9
Created Get PR branch names step, renamed branches
CharlesDuboisSAP Jan 24, 2024
62bfd52
Changed branch var, renamed branches
CharlesDuboisSAP Jan 24, 2024
f662f92
Typo git tag
CharlesDuboisSAP Jan 24, 2024
eb44f6f
Fix download step and cleaned branch names step
CharlesDuboisSAP Jan 24, 2024
1c61f79
Added TODOs, another GIT_TAG try
CharlesDuboisSAP Jan 25, 2024
630af3f
Changed download to fork repo
CharlesDuboisSAP Jan 25, 2024
384afa9
Release 5.3.0 (#26)
github-actions[bot] Jan 25, 2024
a05e544
Updated branch names for 5.2.0 release
CharlesDuboisSAP Jan 25, 2024
be37547
Release 5.2.0 (#27)
github-actions[bot] Jan 25, 2024
f20c830
Fixed release notes PR merge error
CharlesDuboisSAP Jan 25, 2024
34e7b0b
Merge remote-tracking branch 'Johannes-fork/main' into johannes-main
CharlesDuboisSAP Jan 25, 2024
9caf68d
Merge branch 'main' into johannes-main
CharlesDuboisSAP Jan 25, 2024
1caa8f5
Revert docs branches to normal names
CharlesDuboisSAP Jan 25, 2024
508ccaf
Release 5.2.0 (#28)
github-actions[bot] Jan 25, 2024
fbe3f28
Added GH_TOKEN to publish draft release
CharlesDuboisSAP Jan 25, 2024
c0e1110
Release 5.2.0 (#29)
github-actions[bot] Jan 25, 2024
4784e24
Updated git tag to publish draft release
CharlesDuboisSAP Jan 25, 2024
83a24b8
Updated cloud-sdk working dir in prepare release and deleted dir
CharlesDuboisSAP Jan 25, 2024
1592037
Fixed cloud-sdk working dir
CharlesDuboisSAP Jan 25, 2024
5bad446
Release 5.2.0 (#30)
github-actions[bot] Jan 25, 2024
c27aab3
Fixed Publish the Draft Release
CharlesDuboisSAP Jan 25, 2024
4fc9a0a
Release 5.2.0 (#31)
github-actions[bot] Jan 25, 2024
c47cc6b
Do not add cloud-sdk-docs dir during reset release notes
CharlesDuboisSAP Jan 25, 2024
45def33
Skip reset if no changes in release notes
CharlesDuboisSAP Jan 25, 2024
a8d9c0e
git rm .cloud-sdk-docs
CharlesDuboisSAP Jan 25, 2024
480a887
git rm -r ./.cloud-sdk-docs
CharlesDuboisSAP Jan 25, 2024
1f5c93d
git clean -d -x -f
CharlesDuboisSAP Jan 25, 2024
f0158a2
rm -rf .cloud-sdk-docs
CharlesDuboisSAP Jan 25, 2024
2fc3ec3
Release 5.2.0 (#32)
github-actions[bot] Jan 25, 2024
a0070e3
Retry on Merge Release Notes PR
CharlesDuboisSAP Jan 25, 2024
ef0125f
Merge remote-tracking branch 'Johannes-fork/main' into johannes-main
CharlesDuboisSAP Jan 25, 2024
ce94fc8
Release 5.2.0 (#33)
github-actions[bot] Jan 25, 2024
44f6423
refactor: resolve some todos
Jan 26, 2024
ba09748
Merge branch 'SAP:main' into main
Johannes-Schneider Jan 26, 2024
a603da7
Release 5.3.0 (#36)
github-actions[bot] Jan 26, 2024
b5a55c9
feat: introduce manual trigger for perform release workflow
Jan 26, 2024
ae829fe
Merge remote-tracking branch 'origin/main'
Jan 26, 2024
db5438c
fix: use correct repo
Jan 26, 2024
c35a0a6
Release 5.4.0 (#38)
github-actions[bot] Jan 26, 2024
d5c9b1b
fix: use correct docs repo
Jan 26, 2024
50db757
Release 5.5.0 (#39)
github-actions[bot] Jan 26, 2024
a1dc29b
refactor: resolve open TODOs
Jan 26, 2024
fb1cce3
fix: update search link in README.md
Jan 26, 2024
ef14c40
fix: revert unrelated changes
Jan 26, 2024
90aabaf
Merge branch 'SAP:main' into main
Johannes-Schneider Jan 26, 2024
8dacf4f
fix: revert unrelated changes
Jan 26, 2024
c87e69b
fix: make sure release PRs are actually okay
Jan 26, 2024
7782b80
fix: code PR body
Jan 26, 2024
7a2a571
fix: misplaced bracket
Jan 26, 2024
38becb0
fix: update link to maven central in readme.md
Jan 26, 2024
489378b
fix: exclude perform release run
Jan 26, 2024
cfe6e36
Release 5.3.0 (#41)
github-actions[bot] Jan 26, 2024
86350e9
Revert "Release 5.3.0"
Johannes-Schneider Jan 26, 2024
c07579f
Merge pull request #42 from Johannes-Schneider/revert-41-RELEASE-5.3.0
Jan 26, 2024
ced9c44
fix: resolve open TODOs
Jan 26, 2024
46bc064
refactor: release documentation
Jan 29, 2024
16f5928
fix: remove archetype version
Jan 29, 2024
08b704e
refactor: publish draft release before merging PRs
Jan 29, 2024
17db073
Merge remote-tracking branch 'original/main'
Jan 31, 2024
3cc4f98
chore: remove mentions of archetype integration test module
Jan 31, 2024
d8a913d
fix: remove left-over action
Jan 31, 2024
cfb86c6
refactor: only check whether PRs have been approved when performing t…
Jan 31, 2024
19e4e1f
Merge branch 'main' into main
Jan 31, 2024
e27d2e5
refactor: move pr check in reusable action
Feb 1, 2024
e135b37
throwaway: comment QA to speed up testing
Feb 1, 2024
912db4d
throwaway: change to forked docs repo
Feb 1, 2024
838fd38
feat: exclude the current workflow from the checks that need to pass
Feb 1, 2024
a405f93
throwaway: disable pr check for testing
Feb 1, 2024
6bc14bf
throwaway: disable reusable action for testing
Feb 1, 2024
432f48b
fix: matrix tasks
Feb 1, 2024
008a4cc
fix: matrix tasks
Feb 1, 2024
8f32e1a
fix: re-enable reusable action
Feb 1, 2024
b51acbf
fix: hard-code docs repo in matrix
Feb 1, 2024
5f66e3b
fix: hard-code docs repo in matrix
Feb 1, 2024
9218d73
fix: re-use action inputs
Feb 1, 2024
3a2a1f9
fix: default excluded workflow name
Feb 1, 2024
93d9b56
fix: remove additional log
Feb 1, 2024
b811247
chore: add debug log statement
Feb 1, 2024
aa2f13e
fix: workflow exclusions
Feb 1, 2024
448f005
fix: workflow exclusions
Feb 1, 2024
f2b2cf2
fix: check for failed check runs
Feb 1, 2024
488b763
fix: jq issue
Feb 1, 2024
f968654
chore: revert throwaway commits
Feb 1, 2024
5c1f167
fix: limit perform release runs
Feb 1, 2024
ede7e86
Merge branch 'main' into main
Feb 5, 2024
2f9ee0e
refactor: perform release is now only triggered manually
Feb 6, 2024
fc446db
feat: add toggle to skip PR validation and merging
Feb 6, 2024
36646a2
fix: slightly adjust caching pathes
Feb 6, 2024
d65214e
fix: do not cache the archetype catalog
Feb 6, 2024
7cfa6eb
fix: m2 root path
Feb 6, 2024
6ae759d
fix: use bot PAT token so that subsequent workflows are triggered cor…
Feb 6, 2024
37234ac
Merge branch 'main' into main
Feb 6, 2024
6a0e801
refactor: create re-usable action to deploy a snapshot
Feb 6, 2024
e284482
test: pass secret name instead of secret content
Feb 7, 2024
fecb65b
chore: upgrade github actions
Feb 7, 2024
897dbf9
Revert "test: pass secret name instead of secret content"
Feb 7, 2024
e3ae4ec
chore: add comment as to why we are not printing inputs
Feb 7, 2024
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
100 changes: 100 additions & 0 deletions .github/actions/await-workflow/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: "Await Workflow"
description: "Waits until a workflow run completes."

inputs:
run-id:
description: "The id of the workflow run to wait for."
required: true
poll-interval:
description: "The interval (in seconds) to poll for the workflow run status."
required: false
default: "60"
commit-status:
description: "The commit status message. Leave empty to not create a commit status."
required: false

outputs:
succeeded:
description: "Whether the triggered run succeeded."
value: ${{ steps.wait-for-workflow.outputs.RUN_SUCCEEDED }}
conclusion:
description: "The conclusion of the triggered workflow run."
value: ${{ steps.wait-for-workflow.outputs.CONCLUSION }}

runs:
using: composite
steps:
- name: Print Action Input
run: |
echo "[DEBUG] Starting 'Await Workflow' Action; inputs = ${{ toJson(inputs) }}"
shell: bash

- name: View Run
if: ${{ inputs.commit-status != '' }}
id: view-run
env:
GH_TOKEN: ${{ github.token }}
run: |
JSON=$(gh run view ${{ inputs.run-id }} --json url,headSha)
echo "URL=$(echo $JSON | jq -r '.url')" >> $GITHUB_OUTPUT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Minor/Nitpick)

Weird echo "... $(echo ...)" nesting, but I don't have an immediate suggestion.

echo "HEAD_SHA=$(echo $JSON | jq -r '.headSha')" >> $GITHUB_OUTPUT
shell: bash

- name: Create Commit Status
if: ${{ inputs.commit-status != '' }}
uses: actions/github-script@v7
with:
script: |
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: '${{ steps.view-run.outputs.HEAD_SHA }}',
state: 'pending',
target_url: '${{ steps.view-run.outputs.URL }}',
context: '${{ inputs.commit-status }}'
})
- name: Wait for Workflow to Complete
id: wait-for-workflow
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "[DEBUG] Waiting for run '${{ inputs.run-id }}' to complete..."
gh run watch ${{ inputs.run-id }} --interval ${{ inputs.poll-interval }} > /dev/null
CONCLUSION=$(gh run view ${{ inputs.run-id }} --json conclusion | jq -r '.conclusion')
echo "CONCLUSION=$CONCLUSION" >> $GITHUB_OUTPUT
echo "[DEBUG] Run '${{ inputs.run-id }}' finished with conclusion '$CONCLUSION'."
if [[ "$CONCLUSION" != "success" ]]; then
echo "RUN_SUCCEEDED=false" >> $GITHUB_OUTPUT
exit 1
fi
echo "RUN_SUCCEEDED=true" >> $GITHUB_OUTPUT
shell: bash

- name: Determine Final Commit Status
id: determine-final-commit-status
if: ${{ always() && inputs.commit-status != '' }}
run: |
if [[ "${{ steps.wait-for-workflow.outputs.CONCLUSION }}" == "success" ]]; then
echo "FINAL_COMMIT_STATUS=success" >> $GITHUB_OUTPUT
else
echo "FINAL_COMMIT_STATUS=failure" >> $GITHUB_OUTPUT
fi
shell: bash

- name: Update Commit Status
if: ${{ always() && inputs.commit-status != '' }}
uses: actions/github-script@v7
with:
script: |
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: '${{ steps.view-run.outputs.HEAD_SHA }}',
state: '${{ steps.determine-final-commit-status.outputs.FINAL_COMMIT_STATUS }}',
target_url: '${{ steps.view-run.outputs.URL }}',
context: '${{ inputs.commit-status }}'
})
106 changes: 106 additions & 0 deletions .github/actions/pr-is-mergeable/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: "PR Is Mergeable"
description: "Checks whether the provided PR is approved and all status checks either succeeded or have been skipped"

inputs:
pr-ref:
description: "The reference (i.e. either number or a branch) of the PR to check"
required: true
fail-on-unmergeable:
description: "Whether to fail the action if the PR is not mergeable"
required: false
default: "true"
repo:
description: "The repository of the PR"
required: false
default: ${{ github.repository }}
token:
description: "The GitHub access token (with PR read permissions) to access the PR"
required: false
default: ${{ github.token }}
excluded-check-runs:
description: "A comma-separated list of workflow names that are excluded from the Check Runs check"
required: false
default: ${{ github.workflow }}

outputs:
pr-number:
description: "The number of the PR that was checked"
value: ${{ steps.check.outputs.PR_NUMBER }}
is-mergeable:
description: "Whether the PR is mergeable"
value: ${{ steps.check.outputs.RESULT }}

runs:
using: composite
steps:
- name: "Print Action Start"
run: echo ">>>>> Starting PR Is Mergeable Action; inputs = ${{ toJson(inputs) }}"
shell: bash

- name: "Check Whether PR Is Mergeable"
id: check
run: |
PR_JSON=$(gh pr view "${{ inputs.pr-ref }}" --repo "${{ inputs.repo }}" --json number,mergeable,reviewDecision,statusCheckRollup)
PR_NUMBER=$(jq -r '.number' <<< "$PR_JSON")
PR_MERGEABLE=$(jq -r '.mergeable' <<< "$PR_JSON")
PR_DECISION=$(jq -r '.reviewDecision' <<< "$PR_JSON")
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
echo "[DEBUG] PR #$PR_NUMBER (in ${{ inputs.repo }}) is mergeable: $PR_MERGEABLE with decision $PR_DECISION"
if [[ "$PR_DECISION" != "APPROVED" ]]; then
echo "PR #$PR_NUMBER (in ${{ inputs.repo }}) has not been approved."
echo "RESULT=false" >> $GITHUB_OUTPUT
exit 0
fi
if [[ "$PR_MERGEABLE" != "MERGEABLE" ]]; then
echo "PR #$PR_NUMBER (in ${{ inputs.repo }}) is not mergeable (i.e. there are conflicts)."
echo "RESULT=false" >> $GITHUB_OUTPUT
exit 0
fi
PR_CHECKS=$(jq -r '.statusCheckRollup' <<< "$PR_JSON")
# check runs are things like our CI pipeline
FAILED_CHECK_RUNS=$(jq -r '.[] | select(.__typename == "CheckRun" and .conclusion != "SUCCESS" and .conclusion != "NEUTRAL")' <<< "$PR_CHECKS")
IFS=',' read -ra EXCLUDED_WORKFLOWS <<< "${{ inputs.excluded-check-runs }}"
for EXCLUDED_WORKFLOW in "${EXCLUDED_WORKFLOWS[@]}"; do
if [[ -z "$FAILED_CHECK_RUNS" ]]; then
break
fi
FAILED_CHECK_RUNS=$(jq -r 'select(.workflowName != "$EXCLUDED_WORKFLOW")' <<< "$FAILED_CHECK_RUNS")
done
if [[ -n "$FAILED_CHECK_RUNS" ]]; then
echo "PR #$PR_NUMBER (in ${{ inputs.repo }}) contains failed check runs: "
echo "$FAILED_CHECK_RUNS"
echo "RESULT=false" >> $GITHUB_OUTPUT
exit 0
fi
# context checks are things like the license agreement check
FAILED_CONTEXT_CHECKS=$(jq -r '.[] | select(.__typename == "StatusContext" and .state != "SUCCESS" and .state != "NEUTRAL")' <<< "$PR_CHECKS")
if [[ -n "$FAILED_CONTEXT_CHECKS" ]]; then
echo "PR #$PR_NUMBER (in ${{ inputs.repo }}) contains failed context checks: "
echo "$FAILED_CONTEXT_CHECKS"
echo "RESULT=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "RESULT=true" >> $GITHUB_OUTPUT
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}

- name: "Fail If PR Is Not Mergeable"
if: ${{ inputs.fail-on-unmergeable == 'true' && steps.check.outputs.RESULT != 'true' }}
run: exit 1
shell: bash

- name: "Print Action End"
if: always()
run: echo "<<<<< Finished PR Is Mergeable Action"
shell: bash
37 changes: 37 additions & 0 deletions .github/actions/scan-with-blackduck/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Scan with BlackDuck"
description: "Scans the project with BlackDuck"

runs:
using: composite
steps:
- name: Print Action Start
run: echo ">>>>> Starting Scan with BlackDuck Action; inputs = ${{ toJson(inputs) }}"
shell: bash

- name: Get Major Version
id: get-major-version
run: echo "MAJOR_VERSION=$(cat latest.json | jq -r .version | cut -d '.' -f 1)" >> $GITHUB_OUTPUT
shell: bash

- name: Determine Maven Excludes
id: get-maven-excludes-for-blackduck
run: python .pipeline/scripts/get-maven-excludes.py --filter-key excludeFromBlackDuckScan --filter-value True
shell: bash

- name: BlackDuck Scan
uses: SAP/project-piper-action@master

Check warning on line 22 in .github/actions/scan-with-blackduck/action.yaml

View check run for this annotation

In Solidarity / Inclusive Language

Match Found

Please consider an alternative to `master`. Possibilities include: `primary`, `main`, `leader`, `active`, `writer`
Raw output
/\b(?!masterdata|masterdata\w+\b)master/gi
with:
command: detectExecuteScan
flags: \
--version=$PROJECT_VERSION \
env:
PIPER_token: ${{ secrets.BLACKDUCK_TOKEN }}
DETECT_MAVEN_EXCLUDED_MODULES: ${{ steps.get-maven-excludes-for-blackduck.outputs.EXCLUDES }}
DETECT_MAVEN_BUILD_COMMAND: -pl ${{ steps.get-maven-excludes-for-blackduck.outputs.PREFIXED_EXCLUDES }}
DETECT_TIMEOUT: "7200"
PROJECT_VERSION: ${{ steps.get-major-version.outputs.MAJOR_VERSION }}

- name: Print Action End
if: always()
run: echo "<<<<< Finished Scan with BlackDuck Action"
shell: bash
67 changes: 67 additions & 0 deletions .github/actions/trigger-workflow/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: "Trigger Workflow"
description: "Triggers a workflow without waiting for it to complete."

inputs:
workflow:
description: "The workflow file name"
required: true
workflow-ref:
description: "The ref (i.e. branch name, or tag name) where the workflow is located."
required: true
parameters:
description: "The workflow parameters"
required: false
commit-sha:
description: "The commit SHA to trigger the workflow on"
required: false
default: ${{ github.sha }}

outputs:
run-id:
description: "The id of the workflow run that was triggered."
value: ${{ steps.trigger-workflow.outputs.RUN_ID }}
run-url:
description: "The url of the workflow run that was triggered."
value: ${{ steps.trigger-workflow.outputs.RUN_URL }}

runs:
using: composite
steps:
- name: Print Action Input
run: |
echo "[DEBUG] Starting 'Trigger Workflow' Action; inputs = ${{ toJson(inputs) }}"
shell: bash

- name: Trigger Workflow
id: trigger-workflow
env:
GH_TOKEN: ${{ github.token }}
run: |
PREVIOUS_RUN_ID=$(gh run list --workflow=${{ inputs.workflow}} --commit=${{ inputs.commit-sha }} --json databaseId | jq -r '.[0].databaseId')
echo "[DEBUG] Previous run id = '$PREVIOUS_RUN_ID'"

gh workflow run "${{ inputs.workflow }}" --ref "${{ inputs.workflow-ref }}" ${{ inputs.parameters }}
# allow for some initial delay as workflows take a moment to spin up
sleep 20

for i in {0..6}; do
LATEST_RUN_ID=$(gh run list --workflow=${{ inputs.workflow }} --commit=${{ inputs.commit-sha }} --json databaseId | jq -r '.[0].databaseId')

if [[ -z "$LATEST_RUN_ID" || "$LATEST_RUN_ID" == "$PREVIOUS_RUN_ID" ]]; then
echo "[DEBUG] No new run detected. Waiting for 10 seconds."
sleep 10
else
echo "[DEBUG] New workflow run detected: '$LATEST_RUN_ID'."

RUN_URL=$(gh run view $LATEST_RUN_ID --json url | jq -r '.url')
echo "[DEBUG] ${{ inputs.workflow }} run #$LATEST_RUN_ID successfully triggered: $RUN_URL"
echo "[${{ inputs.workflow }} run (#$LATEST_RUN_ID)]($RUN_URL)" >> $GITHUB_STEP_SUMMARY
echo "RUN_ID=$LATEST_RUN_ID" >> $GITHUB_OUTPUT
echo "RUN_URL=$RUN_URL" >> $GITHUB_OUTPUT
exit 0
fi
done

echo "[DEBUG] Unable to detect new run of workflow '${{ inputs.workflow }}'."
exit 1
shell: bash
35 changes: 4 additions & 31 deletions .github/workflows/blackduck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,17 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
- run: git fetch --depth=1
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
cache: maven
- uses: actions/checkout@v4
- name: "Scan With Black Duck"
uses: ./.github/actions/scan-with-blackduck

# Fixme: Use major version from pom once it is 5.x
- name: Get SDK Version
run: |
echo "project_version_NOT_YET_IN_USE=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | cut -d '.' -f 1)" >> $GITHUB_ENV

- name: Determine Maven Excludes
run: |
python .pipeline/scripts/get-maven-excludes.py --filter-key excludeFromBlackDuckScan --filter-value True
id: get-maven-excludes-for-blackduck

- name: Blackduck Scan
uses: SAP/project-piper-action@27cadf261545552a68660531476c0915a97ee3d8
with:
command: detectExecuteScan
flags: \
--version=$PROJECT_VERSION \
env:
PIPER_token: ${{ secrets.BLACKDUCK_TOKEN }}
DETECT_MAVEN_EXCLUDED_MODULES: ${{ steps.get-maven-excludes-for-blackduck.outputs.EXCLUDES }}
DETECT_MAVEN_BUILD_COMMAND: -pl ${{ steps.get-maven-excludes-for-blackduck.outputs.PREFIXED_EXCLUDES }}
DETECT_TIMEOUT: 7200
PROJECT_VERSION: "5"
notify-job:
runs-on: ubuntu-latest
needs: [ scan ]
if: ${{ failure() && github.ref == 'refs/heads/main' }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Notify
run: python .pipeline/scripts/notify.py
env:
Expand Down
Loading
Loading