File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ name: Cleanup Old Workflow Runs
22
33on :
44 schedule :
5- # Run daily at 2 AM UTC
65 - cron : ' 0 2 * * *'
76 workflow_dispatch :
87 inputs :
1413jobs :
1514 cleanup :
1615 runs-on : ubuntu-latest
17- timeout-minutes : 20
16+ timeout-minutes : 30
1817 concurrency :
1918 group : workflow-cleanup
2019 cancel-in-progress : false
4140 });
4241
4342 let deletedCount = 0;
43+ let failedCount = 0;
4444 for (const workflow of workflows) {
4545 const runs = await github.paginate(github.rest.actions.listWorkflowRuns, {
4646 owner,
6060 await github.rest.actions.deleteWorkflowRun({ owner, repo, run_id: run.id });
6161 deletedCount++;
6262 } catch (error) {
63+ failedCount++;
6364 console.log(`Failed to delete run ${run.id}: ${error.message}`);
6465 }
6566 }
6667 }
6768
68- console.log(`Deleted ${deletedCount} workflow runs`);
69+ console.log(`Deleted ${deletedCount} workflow runs, ${failedCount} failures `);
Original file line number Diff line number Diff line change 66 - main
77 workflow_dispatch :
88
9+ permissions :
10+ contents : read
11+
912concurrency :
1013 group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1114 cancel-in-progress : true
1821 uses : ./.github/workflows/scan.yml
1922
2023 pull-request :
21- needs : test
24+ needs : [ test, scan]
2225 name : Pull request success
2326 runs-on : ubuntu-latest
2427 steps :
Original file line number Diff line number Diff line change 1- # Copyright the Hyperledger Fabric contributors. All rights reserved.
2- # SPDX-License-Identifier: Apache-2.0
3-
41name : Push
52
63on :
96 - main
107 workflow_dispatch :
118
9+ permissions :
10+ contents : read
11+
1212jobs :
1313 test :
14- uses : ./.github/workflows/test.yaml
14+ uses : ./.github/workflows/test.yaml
15+
16+ scan :
17+ uses : ./.github/workflows/scan.yml
Original file line number Diff line number Diff line change 99
1010permissions :
1111 contents : read
12- packages : write
1312
1413jobs :
1514 release :
1615 runs-on : ubuntu-latest
16+ timeout-minutes : 20
1717 permissions :
1818 contents : read
19- packages : write
2019
2120 steps :
2221 - uses : actions/checkout@v4
@@ -32,16 +31,16 @@ jobs:
3231 - name : Install build dependencies
3332 run : |
3433 python -m pip install --upgrade pip
35- pip install build setuptools wheel
34+ python -m pip install build setuptools wheel
3635
3736 - name : Build distribution
38- run : |
39- python -m build --sdist --wheel
37+ run : python -m build --sdist --wheel
4038
39+ # Recommended future improvement: migrate to Trusted Publishing (OIDC).
40+ # Requires: permissions: id-token: write, remove 'password',
41+ # and configure the publisher on pypi.org.
4142 - name : Publish to PyPI
4243 if : startsWith(github.ref, 'refs/tags/')
4344 uses : pypa/gh-action-pypi-publish@release/v1
4445 with :
45- password : ${{ secrets.PYPI_API_TOKEN }}
46- repository : ${{ github.repository }}
47- skip_existing_packages : true
46+ password : ${{ secrets.PYPI_API_TOKEN }}
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ permissions:
1515jobs :
1616 scan :
1717 runs-on : ubuntu-latest
18+ timeout-minutes : 15
19+
1820 steps :
1921 - uses : actions/checkout@v4
2022 with :
@@ -27,13 +29,16 @@ jobs:
2729 python-version : ' 3.11'
2830 cache : ' pip'
2931
30- - name : Install dependencies for scanning
32+ - name : Install project dependencies
3133 run : |
3234 python -m pip install --upgrade pip
33- python -m pip install safety
35+ python -m pip install -r requirements.txt
36+
37+ - name : Install pip-audit
38+ run : python -m pip install pip-audit
3439
35- - name : Scan dependencies
36- run : safety check --full-report
40+ - name : Audit requirements.txt
41+ run : pip-audit -r requirements.txt
3742
38- - name : Scan source code
39- run : safety check -r requirements.txt
43+ - name : Audit installed environment
44+ run : pip-audit
Original file line number Diff line number Diff line change 1- # Copyright the Hyperledger Fabric contributors. All rights reserved.
2- # SPDX-License-Identifier: Apache-2.0
3-
41name : Test
52
63on :
7- pull_request :
8- branches :
9- - main
10- push :
11- branches :
12- - main
134 workflow_call :
145
15- concurrency :
16- group : ${{ github.workflow }}-${{ github.ref }}
17- cancel-in-progress : true
18-
196permissions :
207 contents : read
218
4128 python -m pip install -r requirements.txt pytest pytest-asyncio
4229
4330 - name : Run tests
44- run : |
45- python -m pytest -q
31+ run : python -m pytest -q
Original file line number Diff line number Diff line change 1- name : " Security vulnerability scan"
1+ name : " Scheduled vulnerability scan"
22
33on :
44 schedule :
@@ -12,11 +12,20 @@ jobs:
1212 latest-release-version :
1313 name : Get latest release tag
1414 runs-on : ubuntu-latest
15+ timeout-minutes : 5
1516 outputs :
1617 tag_name : ${{ steps.tag-name.outputs.value }}
1718 steps :
1819 - id : tag-name
19- run : echo "value=$(curl --location --silent --fail "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/latest" | jq --raw-output '.tag_name')" >> "${GITHUB_OUTPUT}"
20+ env :
21+ GH_TOKEN : ${{ github.token }}
22+ run : |
23+ tag="$(gh api "repos/${GITHUB_REPOSITORY}/releases/latest" --jq '.tag_name')"
24+ if [ -z "${tag}" ] || [ "${tag}" = "null" ]; then
25+ echo "::error::No releases found in ${GITHUB_REPOSITORY}"
26+ exit 1
27+ fi
28+ echo "value=${tag}" >> "${GITHUB_OUTPUT}"
2029
2130 scan :
2231 name : Scan ${{ needs.latest-release-version.outputs.tag_name }}
You can’t perform that action at this time.
0 commit comments