Skip to content

Commit

Permalink
Improve workflows (#296)
Browse files Browse the repository at this point in the history
- Adds new workflow for OSSF Scorecard
- Makes test workflow always run when "main" changes
- Fixes permissions of CodeQL workflow
- Makes CodeQL workflow always run when "main" changes
- Fixes the permissions of release trigger workflow
- Fixes release draft workflow permissions
- Switches to new Gradle Wrapper validation action

{patch}

Signed-off-by: Esta Nagy <[email protected]>
  • Loading branch information
nagyesta authored Aug 3, 2024
1 parent ff06713 commit c4e8429
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 25 deletions.
24 changes: 5 additions & 19 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,6 @@ name: "CodeQL"
on:
push:
branches: [ main ]
paths-ignore:
- 'README.md'
- '**/README.md'
- 'CODE_OF_CONDUCT.md'
- 'CONTRIBUTING.md'
- 'pull_request_template.md'
- 'SECURITY.md'
- 'LICENSE'
- '.github/ISSUE_TEMPLATE/**'
- '.github/assets/**'
- '.github/workflows/**'
- '!.github/workflows/codeql-analysis.yml'
- '.github/pr-labeler.yml'
- 'renovate.json'
- '.whitesource'
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
Expand All @@ -51,9 +36,6 @@ on:
- 'gradle/libs.versions.toml'

permissions:
# required for all workflows
security-events: write

# only required for workflows in private repositories
actions: read
contents: read
Expand All @@ -63,11 +45,15 @@ jobs:
name: Analyze
runs-on: ubuntu-latest

permissions:
# required for all workflows
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@f9c9c575b8b21b6485636a91ffecd10e558c62f6 # v3.5.0
uses: gradle/actions/wrapper-validation@d9c87d481d55275bb5441eef3fe0e46805f9ef70 # v3.5.0
- name: Set up JDK 17
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/gradle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ name: JavaCI-PR
on:
push:
branches: [ main ]
paths:
- 'gradle/libs.versions.toml'
- 'gradle/verification-metadata.xml'
- 'gradle/wrapper/gradle-wrapper.properties'
- 'config/ossindex/exclusions.txt'
- '.github/workflows/gradle-ci.yml'
pull_request:
branches: [ main ]
paths-ignore:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/release-draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ on:
tags:
- v*

permissions:
contents: read

jobs:
build:
name: Draft release action
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Create release
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:
# * is a special character in YAML, so we have to quote this string
- cron: '0 4 25 * *'

permissions:
contents: read

jobs:
build:
name: Release trigger action
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.

name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '31 19 * * 3'
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

# Declare default permissions as read only.
permissions: read-all

jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
# Uncomment the permissions below if installing in a private repository.
# contents: read
# actions: read

steps:
- name: "Checkout code"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecard on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
# repo_token: ${{ secrets.SCORECARD_TOKEN }}

# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories:
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
publish_results: true

# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.pre.node20
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard (optional).
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15
with:
sarif_file: results.sarif

0 comments on commit c4e8429

Please sign in to comment.