-
Notifications
You must be signed in to change notification settings - Fork 1
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
ci: sync workflows from central-workflows #19
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# 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. | ||
|
||
# This workflow checks out code, performs a Codacy security scan | ||
# and integrates the results with the | ||
# GitHub Advanced Security code scanning feature. For more information on | ||
# the Codacy security scan action usage and parameters, see | ||
# https://github.com/codacy/codacy-analysis-cli-action. | ||
# For more information on Codacy Analysis CLI in general, see | ||
# https://github.com/codacy/codacy-analysis-cli. | ||
|
||
name: Codacy Security Scan | ||
|
||
on: | ||
push: | ||
branches: [ "dev", "main" ] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: [ "dev", "main" ] | ||
schedule: | ||
- cron: '17 0 * * 4' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
codacy-security-scan: | ||
permissions: | ||
contents: read # for actions/checkout to fetch code | ||
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results | ||
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status | ||
name: Codacy Security Scan | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout the repository to the GitHub Actions runner | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis | ||
- name: Run Codacy Analysis CLI | ||
uses: codacy/codacy-analysis-cli-action@3ff8e64eb4b714c4bee91b7b4eea31c6fc2c4f93 | ||
with: | ||
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository | ||
# You can also omit the token and run the tools that support default configurations | ||
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | ||
verbose: true | ||
output: results.sarif | ||
format: sarif | ||
# Adjust severity of non-security issues | ||
gh-code-scanning-compat: true | ||
# Force 0 exit code to allow SARIF file generation | ||
# This will handover control about PR rejection to the GitHub side | ||
max-allowed-issues: 2147483647 | ||
|
||
# Upload the SARIF file generated in the previous step | ||
- name: Upload SARIF results file | ||
uses: github/codeql-action/upload-sarif@v3 | ||
with: | ||
sarif_file: results.sarif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# For most projects, this workflow file will not need changing; you simply need | ||
# to commit it to your repository. | ||
# | ||
# You may wish to alter this file to override the set of languages analyzed, | ||
# or to provide custom queries or build logic. | ||
# | ||
# ******** NOTE ******** | ||
# We have attempted to detect the languages in your repository. Please check | ||
# the `language` matrix defined below to confirm you have the correct set of | ||
# supported CodeQL languages. | ||
# | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: [ "dev", "main" ] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: [ "dev", "main" ] | ||
schedule: | ||
- cron: '34 0 * * 4' | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: [ 'javascript' ] | ||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] | ||
# Use only 'java' to analyze code written in Java, Kotlin or both | ||
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both | ||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
# Initializes the CodeQL tools for scanning. | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v3 | ||
with: | ||
languages: ${{ matrix.language }} | ||
# If you wish to specify custom queries, you can do so here or in a config file. | ||
# By default, queries listed here will override any specified in a config file. | ||
# Prefix the list here with "+" to use these queries and those in the config file. | ||
|
||
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs | ||
# queries: security-extended,security-and-quality | ||
|
||
|
||
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). | ||
# If this step fails, then you should remove it and run the build manually (see below) | ||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v3 | ||
|
||
# ℹ️ Command-line programs to run using the OS shell. | ||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun | ||
|
||
# If the Autobuild fails above, remove it and uncomment the following three lines. | ||
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. | ||
|
||
# - run: | | ||
# echo "Run, Build Application using script" | ||
# ./location_of_script_within_repo/buildscript.sh | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v3 | ||
with: | ||
category: "/language:${{matrix.language}}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
Check notice Code scanning / Checkov (reported by Codacy) Ensure top-level permissions are not set to write-all Note
Ensure top-level permissions are not set to write-all
|
||
|
||
# Please do not attempt to edit this flow without the direct consent from the DevOps team. This file is managed centrally. | ||
# Contact @moabu | ||
name: 'Commit Message Check' | ||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- edited | ||
- reopened | ||
- synchronize | ||
push: | ||
branches: [ "dev", "main" ] | ||
|
||
jobs: | ||
check-commit-message: | ||
name: Check Commit Message | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Project | ||
uses: actions/checkout@v4 | ||
with: | ||
# We need to fetch with a depth of 2 for pull_request so we can do HEAD^2 | ||
fetch-depth: 2 | ||
|
||
- uses: actions/[email protected] | ||
with: | ||
node-version: 14 | ||
|
||
- run: | | ||
npm install --save-dev @commitlint/{config-conventional,cli} | ||
echo "module.exports = {extends: ['@commitlint/config-conventional']};" > commitlint.config.js | ||
|
||
# If this workflow was triggered by a push then resolve the commit message from HEAD | ||
- name: "[Push] Check Commit Standard" | ||
if: github.event_name == 'push' || github.event_name == 'pull_request_target' | ||
id: push_get_commit_message | ||
run: | | ||
git log --format=%B -n 1 HEAD | npx commitlint |& tee -a output.txt | ||
echo "::set-output name=errormsg::$(tr -d "\n\r" < output.txt)" | ||
git log --format=%B -n 1 HEAD | npx commitlint | ||
continue-on-error: true | ||
|
||
# If this workflow was triggered by a pull request (open or synchronize!) then resolve the commit message from HEAD^2 | ||
- name: "[Pull Request] Check Commit Standard" | ||
if: github.event_name == 'pull_request' | ||
id: pr_get_commit_message | ||
run: | | ||
git log --format=%B -n 1 HEAD^2 | npx commitlint |& tee -a output.txt | ||
echo "::set-output name=errormsg::$(tr -d "\n\r" < output.txt)" | ||
git log --format=%B -n 1 HEAD^2 | npx commitlint | ||
continue-on-error: true | ||
|
||
- name: "[Push] Report Commit Standard Status" | ||
Check notice Code scanning / Checkov (reported by Codacy) Suspicious use of curl with secrets Note
Suspicious use of curl with secrets
|
||
if: steps.push_get_commit_message.outcome != 'success' && github.event_name == 'push' | ||
run: | | ||
curl -X POST -H 'Content-Type: application/json' --data '{"alias":"Mo-Auto","emoji":":robot:","text":":x: :cry: I am reporting a bad [commit](https://github.com/${{github.repository}}/commit/${{github.sha}}) by :thinking_face: @${{github.actor}} :x:","attachments":[{"title":"GitHub user behavior reporter","title_link":"https://www.conventionalcommits.org","text":"We are not too happy with your last [commit](https://github.com/${{github.repository}}/commit/${{github.sha}}). Here is why : ${{ steps.push_get_commit_message.outputs.errormsg }}","color":"#764FA5"}]}' ${{ secrets.GITHUBUSERBEHAVIORSLACKREPORTER }} | ||
exit 1 | ||
|
||
- name: "[Pull Request] Report Commit Standard Status" | ||
Check notice Code scanning / Checkov (reported by Codacy) Suspicious use of curl with secrets Note
Suspicious use of curl with secrets
|
||
if: steps.pr_get_commit_message.outcome != 'success' && github.event_name == 'pull_request' | ||
run: | | ||
curl -X POST -H 'Content-Type: application/json' --data '{"alias":"Mo-Auto","emoji":":robot:","text":":x: :cry: I am reporting a bad [commit](https://github.com/${{github.repository}}/tree/$GITHUB_HEAD_REF) by :thinking_face: @${{github.actor}} :x:","attachments":[{"title":"GitHub user behavior reporter","title_link":"https://www.conventionalcommits.org","text":"We are not too happy with your last commit merging into https://github.com/${{github.repository}}/tree/${{github.base_ref}}. Here is why : ${{ steps.pr_get_commit_message.outputs.errormsg }}","color":"#764FA5"}]}' ${{ secrets.GITHUBUSERBEHAVIORSLACKREPORTER }} | ||
exit 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
Check notice Code scanning / Checkov (reported by Codacy) Ensure top-level permissions are not set to write-all Note
Ensure top-level permissions are not set to write-all
|
||
|
||
# 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. | ||
|
||
# This GitHub Actions workflow validates the title of pull requests (PRs) to ensure they follow conventional commit standards. | ||
|
||
name: PR Conventional Commit Validation | ||
|
||
on: | ||
# Trigger this workflow on specific events related to pull requests | ||
pull_request: | ||
types: [opened, synchronize, reopened, edited] | ||
|
||
jobs: | ||
validate-pr-title: | ||
runs-on: ubuntu-latest # Use the latest Ubuntu runner for the job | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 # Checkout the repository code using the actions/checkout action | ||
|
||
- name: PR Conventional Commit Validation | ||
uses: ytanikin/[email protected] # Use the PRConventionalCommits action to validate PR titles | ||
Check warning Code scanning / Semgrep (reported by Codacy) An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Warning
An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release.
|
||
with: | ||
# Define the task types that are valid for conventional commits | ||
task_types: '["build","ci","docs","feat","fix","perf","refactor","style","test","feat!"]' | ||
# Map the conventional commit types to corresponding GitHub labels | ||
custom_labels: '{"build": "build", "ci": "CI/CD", "docs": "documentation", "feat": "enhancement", "fix": "bug", "perf": "performance", "refactor": "refactor", "style": "style", "test": "test", "feat!": "enhancement breaking change"}' | ||
# Use a personal access token (GITHUB_TOKEN) stored in GitHub secrets for authentication | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
add_label: 'true' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
Check notice Code scanning / Checkov (reported by Codacy) Ensure top-level permissions are not set to write-all Note
Ensure top-level permissions are not set to write-all
|
||
|
||
# This GitHub Actions workflow checks that all commits in a pull request (PR) have a "Signed-off-by" line to ensure Developer Certificate of Origin (DCO) compliance. | ||
|
||
name: DCO | ||
|
||
# Trigger the workflow on pull request events | ||
on: [pull_request] | ||
|
||
jobs: | ||
dco: | ||
# Define the runner environment | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Step to check out the repository | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all history for all branches to ensure complete commit history is available | ||
|
||
# Step to check each commit in the pull request for a Signed-off-by line | ||
- name: Check for DCO Sign-off | ||
Check notice Code scanning / Checkov (reported by Codacy) Ensure run commands are not vulnerable to shell injection Note
Ensure run commands are not vulnerable to shell injection
|
||
run: | | ||
|
||
# Get the base branch and head branch of the pull request | ||
base_branch=${{ github.event.pull_request.base.ref }} | ||
head_branch=${{ github.event.pull_request.head.ref }} | ||
|
||
# Get the list of commit hashes between the head branch and base branch | ||
commits=$(git log --pretty=format:%H origin/${head_branch}..origin/${base_branch}) | ||
non_compliant_commits="" | ||
|
||
# Loop through each commit and check for the Signed-off-by line | ||
for commit in $commits; do | ||
# Check if the commit message contains the Signed-off-by line | ||
if ! git show --quiet --format=%B $commit | grep -q "^Signed-off-by: "; then | ||
# If not, add the commit hash to the list of non-compliant commits | ||
non_compliant_commits="$non_compliant_commits $commit" | ||
fi | ||
done | ||
|
||
# If there are any non-compliant commits, output their hashes and fail the job | ||
if [ -n "$non_compliant_commits" ]; then | ||
echo "The following commits do not have a Signed-off-by line:" | ||
for commit in $non_compliant_commits; do | ||
echo "- $commit" | ||
done | ||
exit 1 | ||
fi | ||
shell: bash |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Dependency Review Action | ||
# | ||
# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging. | ||
# | ||
# Source repository: https://github.com/actions/dependency-review-action | ||
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement | ||
name: 'Dependency Review' | ||
on: [pull_request] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
dependency-review: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 'Checkout Repository' | ||
uses: actions/checkout@v4 | ||
- name: 'Dependency Review' | ||
uses: actions/dependency-review-action@v4 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# 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. | ||
# hadoint is a Dockerfile linter written in Haskell | ||
# that helps you build best practice Docker images. | ||
# More details at https://github.com/hadolint/hadolint | ||
|
||
name: Hadolint | ||
|
||
on: | ||
push: | ||
branches: [ "dev", "main" ] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: [ "dev" ] | ||
schedule: | ||
- cron: '17 13 * * 0' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
hadolint: | ||
name: Run hadolint scanning | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read # for actions/checkout to fetch code | ||
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results | ||
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run hadolint | ||
uses: hadolint/hadolint-action@f988afea3da57ee48710a9795b6bb677cc901183 | ||
with: | ||
dockerfile: ./Dockerfile | ||
format: sarif | ||
output-file: hadolint-results.sarif | ||
no-fail: true | ||
|
||
- name: Upload analysis results to GitHub | ||
uses: github/codeql-action/upload-sarif@v2 | ||
with: | ||
sarif_file: hadolint-results.sarif | ||
wait-for-processing: true |
Check notice
Code scanning / Checkov (reported by Codacy)
Ensure top-level permissions are not set to write-all Note