Skip to content

Commit 7da478e

Browse files
scott45github-actions
and
github-actions
authored
ci: sync workflows from central-workflows (#140)
* ci: sync workflows from central-workflows Signed-off-by: Scott <[email protected]> * ci: sync workflows from central-workflows Signed-off-by: Scott <[email protected]> * ci: sync workflows from central-workflows Signed-off-by: Scott <[email protected]> --------- Co-authored-by: github-actions <[email protected]>
1 parent 9544029 commit 7da478e

12 files changed

+317
-104
lines changed

.github/workflows/codacy.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
# For more information on Codacy Analysis CLI in general, see
1414
# https://github.com/codacy/codacy-analysis-cli.
1515

16+
# Please do not attempt to edit this flow without the direct consent from the DevOps team. This file is managed centrally.
17+
1618
name: Codacy Security Scan
1719

1820
on:
1921
push:
20-
branches: [ "main" ]
22+
branches: [ "dev", "main" ]
2123
pull_request:
2224
# The branches below must be a subset of the branches above
23-
branches: [ "main" ]
25+
branches: [ "dev", "main" ]
2426
schedule:
2527
- cron: '17 0 * * 4'
2628

@@ -29,6 +31,7 @@ permissions:
2931

3032
jobs:
3133
codacy-security-scan:
34+
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
3235
permissions:
3336
contents: read # for actions/checkout to fetch code
3437
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
@@ -42,7 +45,7 @@ jobs:
4245

4346
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
4447
- name: Run Codacy Analysis CLI
45-
uses: codacy/codacy-analysis-cli-action@d840f886c4bd4edc059706d09c6a1586111c540b
48+
uses: codacy/codacy-analysis-cli-action@3ff8e64eb4b714c4bee91b7b4eea31c6fc2c4f93
4649
with:
4750
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
4851
# You can also omit the token and run the tools that support default configurations
@@ -58,6 +61,6 @@ jobs:
5861

5962
# Upload the SARIF file generated in the previous step
6063
- name: Upload SARIF results file
61-
uses: github/codeql-action/upload-sarif@v2
64+
uses: github/codeql-action/upload-sarif@v3
6265
with:
6366
sarif_file: results.sarif

.github/workflows/codeql.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,23 @@
1111
# the `language` matrix defined below to confirm you have the correct set of
1212
# supported CodeQL languages.
1313
#
14+
15+
# Please do not attempt to edit this flow without the direct consent from the DevOps team. This file is managed centrally.
16+
1417
name: "CodeQL"
1518

1619
on:
1720
push:
18-
branches: [ "main" ]
21+
branches: [ "dev", "main" ]
1922
pull_request:
2023
# The branches below must be a subset of the branches above
21-
branches: [ "main" ]
24+
branches: [ "dev", "main" ]
2225
schedule:
2326
- cron: '34 0 * * 4'
2427

2528
jobs:
2629
analyze:
30+
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
2731
name: Analyze
2832
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
2933
permissions:
@@ -46,7 +50,7 @@ jobs:
4650

4751
# Initializes the CodeQL tools for scanning.
4852
- name: Initialize CodeQL
49-
uses: github/codeql-action/init@v2
53+
uses: github/codeql-action/init@v3
5054
with:
5155
languages: ${{ matrix.language }}
5256
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -60,7 +64,7 @@ jobs:
6064
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
6165
# If this step fails, then you should remove it and run the build manually (see below)
6266
- name: Autobuild
63-
uses: github/codeql-action/autobuild@v2
67+
uses: github/codeql-action/autobuild@v3
6468

6569
# ℹ️ Command-line programs to run using the OS shell.
6670
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -73,6 +77,6 @@ jobs:
7377
# ./location_of_script_within_repo/buildscript.sh
7478

7579
- name: Perform CodeQL Analysis
76-
uses: github/codeql-action/analyze@v2
80+
uses: github/codeql-action/analyze@v3
7781
with:
7882
category: "/language:${{matrix.language}}"

.github/workflows/conventional-commits.yml

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
# This GitHub Actions workflow validates the title of pull requests (PRs) to ensure they follow conventional commit standards.
99

10+
# Please do not attempt to edit this flow without the direct consent from the DevOps team. This file is managed centrally.
11+
1012
name: PR Conventional Commit Validation
1113

1214
on:
@@ -16,6 +18,7 @@ on:
1618

1719
jobs:
1820
validate-pr-title:
21+
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
1922
runs-on: ubuntu-latest # Use the latest Ubuntu runner for the job
2023
steps:
2124
- name: Checkout code

.github/workflows/dco-check.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
# 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.
4+
5+
# Please do not attempt to edit this flow without the direct consent from the DevOps team. This file is managed centrally.
6+
7+
name: DCO
8+
9+
# Trigger the workflow on pull request events
10+
on: [pull_request]
11+
12+
jobs:
13+
dco:
14+
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
15+
# Define the runner environment
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
# Step to check out the repository
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0 # Fetch all history for all branches to ensure complete commit history is available
23+
24+
- name: Set up environment variables
25+
run: |
26+
echo "BASE_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
27+
echo "HEAD_BRANCH=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
28+
29+
# Step to check each commit in the pull request for a Signed-off-by line
30+
- name: Check for DCO Sign-off
31+
run: |
32+
# Get the base branch and head branch of the pull request
33+
base_branch=$BASE_BRANCH
34+
head_branch=$HEAD_BRANCH
35+
36+
# Get the list of commit hashes between the head branch and base branch
37+
commits=$(git log --pretty=format:%H origin/${head_branch}..origin/${base_branch})
38+
non_compliant_commits=""
39+
40+
# Loop through each commit and check for the Signed-off-by line
41+
for commit in $commits; do
42+
# Check if the commit message contains the Signed-off-by line
43+
if ! git show --quiet --format=%B $commit | grep -q "^Signed-off-by: "; then
44+
# If not, add the commit hash to the list of non-compliant commits
45+
non_compliant_commits="$non_compliant_commits $commit"
46+
fi
47+
done
48+
49+
# If there are any non-compliant commits, output their hashes and fail the job
50+
if [ -n "$non_compliant_commits" ]; then
51+
echo "The following commits do not have a Signed-off-by line:"
52+
for commit in $non_compliant_commits; do
53+
echo "- $commit"
54+
done
55+
exit 1
56+
fi
57+
shell: bash

.github/workflows/dependency-review.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#
77
# Source repository: https://github.com/actions/dependency-review-action
88
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
9+
10+
11+
# Please do not attempt to edit this flow without the direct consent from the DevOps team. This file is managed centrally.
12+
913
name: 'Dependency Review'
1014
on: [pull_request]
1115

@@ -19,4 +23,4 @@ jobs:
1923
- name: 'Checkout Repository'
2024
uses: actions/checkout@v4
2125
- name: 'Dependency Review'
22-
uses: actions/dependency-review-action@v3
26+
uses: actions/dependency-review-action@v4
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
# hadoint is a Dockerfile linter written in Haskell
8+
# that helps you build best practice Docker images.
9+
# More details at https://github.com/hadolint/hadolint
10+
11+
# Please do not attempt to edit this flow without the direct consent from the DevOps team. This file is managed centrally.
12+
13+
name: Hadolint
14+
15+
on:
16+
push:
17+
branches: [ "dev", "main" ]
18+
pull_request:
19+
# The branches below must be a subset of the branches above
20+
branches: [ "dev" ]
21+
schedule:
22+
- cron: '17 13 * * 0'
23+
24+
permissions:
25+
contents: read
26+
27+
jobs:
28+
hadolint:
29+
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
30+
name: Run hadolint scanning
31+
runs-on: ubuntu-latest
32+
permissions:
33+
contents: read # for actions/checkout to fetch code
34+
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
35+
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v4
39+
40+
- name: Run hadolint
41+
uses: hadolint/hadolint-action@f988afea3da57ee48710a9795b6bb677cc901183
42+
with:
43+
dockerfile: ./Dockerfile
44+
format: sarif
45+
output-file: hadolint-results.sarif
46+
no-fail: true
47+
48+
- name: Upload analysis results to GitHub
49+
uses: github/codeql-action/upload-sarif@v3
50+
with:
51+
sarif_file: hadolint-results.sarif
52+
wait-for-processing: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
# GitHub recommends pinning actions to a commit SHA.
9+
# To get a newer version, you will need to update the SHA.
10+
# You can also reference a tag or branch, but the action may change without warning.
11+
12+
# Please do not attempt to edit this flow without the direct consent from the DevOps team. This file is managed centrally.
13+
14+
name: Publish Docker image
15+
16+
on:
17+
push:
18+
branches: [ "main" ]
19+
20+
jobs:
21+
push_to_registry:
22+
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
23+
name: Push Docker image to Docker Hub
24+
runs-on: ubuntu-latest
25+
permissions:
26+
packages: write
27+
contents: read
28+
attestations: write
29+
id-token: write
30+
steps:
31+
- name: Check out the repo
32+
uses: actions/checkout@v4
33+
34+
- name: Log in to Docker Hub
35+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
36+
with:
37+
username: ${{ secrets.DOCKER_USERNAME }}
38+
password: ${{ secrets.DOCKER_PASSWORD }}
39+
40+
- name: Set ENV variables
41+
run: |
42+
echo "REPO_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}" >> $GITHUB_ENV
43+
44+
- name: Use the custom ENV variable
45+
run: |
46+
echo $REPO_NAME
47+
48+
- name: Extract metadata (tags, labels) for Docker
49+
id: meta
50+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
51+
with:
52+
images: tazamaorg/${{ env.REPO_NAME }}
53+
tags: |
54+
type=raw,value=2.1.0
55+
56+
- name: Build and push Docker image
57+
id: push
58+
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
59+
with:
60+
context: .
61+
file: ./Dockerfile
62+
push: true
63+
tags: ${{ steps.meta.outputs.tags }}
64+
labels: ${{ steps.meta.outputs.labels }}
65+
build-args: GH_TOKEN=${{ secrets.GH_TOKEN }}
66+
67+
- name: Generate artifact attestation
68+
uses: actions/attest-build-provenance@v1
69+
with:
70+
subject-name: docker.io/tazamaorg/${{ env.REPO_NAME }}
71+
subject-digest: ${{ steps.push.outputs.digest }}
72+
push-to-registry: false
73+
74+
- name: Send Slack Notification
75+
env:
76+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
77+
run: |
78+
curl -X POST -H 'Content-type: application/json' --data '{"blocks": [{"type": "header","text": {"type": "plain_text","text": "New Dockerhub Image published :ship::ship:","emoji": true}},{"type": "section","fields": [{"type": "mrkdwn","text": "*Service:*\n${{ env.REPO_NAME }} "},{"type": "mrkdwn","text": "*Tazama Dockerhub:*\n<https://hub.docker.com/orgs/tazamaorg/repositories>"}]}]}' $SLACK_WEBHOOK_URL

.github/workflows/gpg-verify.yml

+13-3
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,37 @@
22

33
# This GitHub Actions workflow checks that all commits in a pull request (PR) have been verified with GPG signatures.
44

5+
# Please do not attempt to edit this flow without the direct consent from the DevOps team. This file is managed centrally.
6+
57
name: GPG Verify
68

79
on: [pull_request] # Trigger this workflow on pull request events
810

911
jobs:
1012
gpg-verify:
13+
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
1114
runs-on: ubuntu-latest # Use the latest Ubuntu runner for the job
1215
steps:
1316
- uses: actions/checkout@v4 # Checkout the repository code using the actions/checkout action
1417
with:
1518
fetch-depth: 0 # Fetch all history for all branches to ensure we have the full commit history
1619

20+
- name: Set up environment variables
21+
run: |
22+
echo "PR_HEAD_REF=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
23+
echo "PR_BASE_REF=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
24+
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
25+
echo "GITHUB_REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV
26+
1727
- name: Check GPG verification status # Step to check each commit for GPG signature verification
1828
run: |
1929
# Get the list of commits in the pull request
20-
commits=$(git log --pretty=format:%H origin/${{ github.event.pull_request.head.ref }}..origin/${{ github.event.pull_request.base.ref }})
30+
commits=$(git log --pretty=format:%H origin/${PR_HEAD_REF}..origin/${PR_BASE_REF})
2131
2232
# Check the GPG verification status of each commit
2333
for commit in $commits; do
24-
status=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
25-
https://api.github.com/repos/${{ github.repository }}/commits/$commit/check-runs \
34+
status=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
35+
https://api.github.com/repos/$GITHUB_REPOSITORY/commits/$commit/check-runs \
2636
| jq -r '.check_runs[] | select(.name == "GPG verify") | .conclusion')
2737
2838
# If the GPG verification status is not successful, list the commit and exit with a non-zero status

0 commit comments

Comments
 (0)