Skip to content

Commit 42fcc87

Browse files
authored
pin github action hash and add scorecard workflow and fix the issue with latest version (#24)
* pin github action hash and add scorecard workflow * remove github hash pinning hook * add auth token to curl requests
1 parent b149014 commit 42fcc87

File tree

7 files changed

+87
-15
lines changed

7 files changed

+87
-15
lines changed

.github/workflows/scorecard.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# This workflow uses actions that are not certified by GitHub. They are provided
2+
# by a third-party and are governed by separate terms of service, privacy
3+
# policy, and support documentation.
4+
5+
name: Scorecard supply-chain security
6+
on:
7+
# For Branch-Protection check. Only the default branch is supported. See
8+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
9+
branch_protection_rule:
10+
# To guarantee Maintained check is occasionally updated. See
11+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
12+
schedule:
13+
- cron: '44 10 * * 6'
14+
push:
15+
branches: [ "main" ]
16+
17+
# Declare default permissions as read only.
18+
permissions: read-all
19+
20+
jobs:
21+
analysis:
22+
name: Scorecard analysis
23+
runs-on: ubuntu-latest
24+
permissions:
25+
# Needed to upload the results to code-scanning dashboard.
26+
security-events: write
27+
# Needed to publish results and get a badge (see publish_results below).
28+
id-token: write
29+
# Uncomment the permissions below if installing in a private repository.
30+
# contents: read
31+
# actions: read
32+
33+
steps:
34+
- name: "Checkout code"
35+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
36+
with:
37+
persist-credentials: false
38+
39+
- name: "Run analysis"
40+
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
41+
with:
42+
results_file: results.sarif
43+
results_format: sarif
44+
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
45+
# - you want to enable the Branch-Protection check on a *public* repository, or
46+
# - you are installing Scorecard on a *private* repository
47+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
48+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
49+
50+
# Public repositories:
51+
# - Publish results to OpenSSF REST API for easy access by consumers
52+
# - Allows the repository to include the Scorecard badge.
53+
# - See https://github.com/ossf/scorecard-action#publishing-results.
54+
# For private repositories:
55+
# - `publish_results` will always be set to `false`, regardless
56+
# of the value entered here.
57+
publish_results: true
58+
59+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
60+
# format to the repository Actions tab.
61+
- name: "Upload artifact"
62+
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
63+
with:
64+
name: SARIF file
65+
path: results.sarif
66+
retention-days: 5
67+
68+
# Upload the results to GitHub's code scanning dashboard.
69+
- name: "Upload to code-scanning"
70+
uses: github/codeql-action/upload-sarif@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7
71+
with:
72+
sarif_file: results.sarif

.github/workflows/test-local-action-inside-home.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: local-inside-home
2222
steps:
2323
- name: Checkout
24-
uses: actions/checkout@v4
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
2525
- name: Setup Bats and Bats libs
2626
id: setup-bats
2727
uses: ./
@@ -98,7 +98,7 @@ jobs:
9898
name: local-inside-home-cache
9999
steps:
100100
- name: Checkout
101-
uses: actions/checkout@v4
101+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
102102
- name: Setup Bats and Bats libs
103103
id: setup-bats
104104
uses: ./

.github/workflows/test-local-action-with-conditionals.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: local-options
2222
steps:
2323
- name: Checkout
24-
uses: actions/checkout@v4
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
2525
- name: Setup Bats and Bats libs
2626
id: setup-bats
2727
uses: ./

.github/workflows/test-local-action.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: local
2222
steps:
2323
- name: Checkout
24-
uses: actions/checkout@v4
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
2525
- name: Setup Bats and Bats libs
2626
id: setup-bats
2727
uses: ./
@@ -88,7 +88,7 @@ jobs:
8888
name: local-default-no-cache
8989
steps:
9090
- name: Checkout
91-
uses: actions/checkout@v4
91+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
9292
- name: Setup Bats and Bats libs
9393
uses: ./
9494
id: setup-bats

.github/workflows/test-public-action.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
name: public
2323
steps:
2424
- name: Checkout
25-
uses: actions/checkout@v4
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
2626
- name: Setup Bats and Bats libs
2727
id: setup-bats
2828
uses: bats-core/bats-action@main
@@ -89,7 +89,7 @@ jobs:
8989
name: public-no-cache
9090
steps:
9191
- name: Checkout
92-
uses: actions/checkout@v4
92+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
9393
- name: Setup Bats and Bats-libs
9494
uses: bats-core/bats-action@main
9595
id: setup-bats

.github/workflows/update-pre-commit-hooks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Check out code
13-
uses: actions/checkout@v4
13+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
1414
- name: Update pre-commit hooks
1515
uses: brokenpip3/action-pre-commit-update@main
1616
with:

action.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ runs:
109109
steps:
110110
# This action would be much easier if only matrix steps will be supported in a composite action
111111
- name: "Set cache for Bats"
112-
uses: actions/cache@v4
112+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4
113113
if: inputs.bats-install == 'true'
114114
id: bats-cache
115115
with:
@@ -138,14 +138,14 @@ runs:
138138
139139
# From https://github.com/fluxcd/flux2/blob/44d69d6fc0c353e79c1bad021a4aca135033bce8/action/action.yml#L35
140140
if [[ -z "$VERSION" ]] || [[ "$VERSION" = "latest" ]]; then
141-
VERSION=$(curl -fsSL --retry 4 --retry-connrefused https://api.github.com/repos/bats-core/bats-core/releases/latest | grep tag_name | cut -d '"' -f 4)
141+
VERSION=$(curl -fsSL --retry 4 --retry-connrefused -H "Authorization: token ${{ github.token }}" https://api.github.com/repos/bats-core/bats-core/releases/latest | grep tag_name | cut -d '"' -f 4)
142142
fi
143143
[[ $VERSION == v* ]] && VERSION="${VERSION:1}"
144144
145145
mkdir -p ${TEMPDIR}
146146
mkdir -p ${DESTDIR}
147147
148-
curl -sL --retry 4 --retry-connrefused ${URL}/archive/refs/tags/v${VERSION}.tar.gz | tar xz -C ${TEMPDIR} --strip-components 1 && cd ${TEMPDIR}
148+
curl -sL --retry 4 --retry-connrefused -H "Authorization: token ${{ github.token }}" ${URL}/archive/refs/tags/v${VERSION}.tar.gz | tar xz -C ${TEMPDIR} --strip-components 1 && cd ${TEMPDIR}
149149
150150
./install.sh ${DESTDIR}
151151
echo "Bats v${VERSION} installed in ${DESTDIR}"
@@ -191,7 +191,7 @@ runs:
191191
192192
- name: "Set cache for Bats-support"
193193
if: inputs.support-install == 'true'
194-
uses: actions/cache@v4
194+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4
195195
id: support-cache
196196
with:
197197
path: ${{ env.SUPPORT_DESTDIR }}
@@ -233,7 +233,7 @@ runs:
233233
234234
- name: "Set cache for Bats-assert"
235235
if: inputs.assert-install == 'true'
236-
uses: actions/cache@v4
236+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4
237237
id: assert-cache
238238
with:
239239
path: ${{ env.ASSERT_DESTDIR }}
@@ -275,7 +275,7 @@ runs:
275275
276276
- name: "Set cache for Bats-detik"
277277
if: inputs.detik-install == 'true'
278-
uses: actions/cache@v4
278+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4
279279
id: detik-cache
280280
with:
281281
path: ${{ env.DETIK_DESTDIR }}
@@ -316,7 +316,7 @@ runs:
316316
317317
- name: "Set cache for Bats-file"
318318
if: inputs.file-install == 'true'
319-
uses: actions/cache@v4
319+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4
320320
id: file-cache
321321
with:
322322
path: ${{ env.FILE_DESTDIR }}

0 commit comments

Comments
 (0)