-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: synced file(s) with honestbank/.github (#18)
- Loading branch information
1 parent
74b6707
commit a982e9c
Showing
10 changed files
with
413 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Instructions to load new secrets | ||
## 1. Add secret names in the workflows_call -> secrets and mark it as required | ||
## 2. Export the secret name with value as JSON in the run section of the "Loading secrets" job | ||
|
||
name: Secrets Loader | ||
permissions: | ||
contents: read | ||
|
||
on: | ||
workflow_call: | ||
outputs: | ||
encrypted_secrets: | ||
description: "Encrypt loaded secrets in base64 JSON format" | ||
value: ${{ jobs.loading.outputs.encrypted_secrets }} | ||
secrets: | ||
APOLLO_KEY: | ||
required: true | ||
## Add addition secrets here | ||
|
||
env: | ||
GHA_GPG_PASSPHRASE: ${{ secrets.GHA_GPG_PASSPHRASE }} | ||
|
||
jobs: | ||
loading: | ||
name: loading | ||
runs-on: ubuntu-latest | ||
outputs: | ||
encrypted_secrets: ${{ steps.loading.outputs.encrypted_secrets }} | ||
steps: | ||
- name: Loading secrets | ||
id: loading | ||
run: | | ||
PLAINTEXT_JSON=$(cat <<EOM | ||
{ | ||
"APOLLO_KEY": "${{ secrets.APOLLO_KEY }}" | ||
## Add addition secrets here (With comma separated JSON format) | ||
} | ||
EOM | ||
) | ||
ENCRYPTED_SECRET=$(echo "$PLAINTEXT_JSON" | gpg --symmetric --cipher-algo AES256 --batch --yes --passphrase "$GHA_GPG_PASSPHRASE" | base64 | tr -d '\n') | ||
echo "encrypted_secrets=$ENCRYPTED_SECRET" >> $GITHUB_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,60 @@ | ||
# DO NOT CHANGE. This file is being managed from a central repository | ||
# To know more simply visit https://github.com/honestbank/.github/blob/main/docs/about.md | ||
|
||
default_install_hook_types: [ pre-commit, commit-msg ] | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: end-of-file-fixer | ||
stages: [commit] | ||
- id: trailing-whitespace | ||
stages: [commit] | ||
- id: check-yaml | ||
args: [ '--allow-multiple-documents' ] | ||
stages: [commit] | ||
args: ["--allow-multiple-documents"] | ||
- id: detect-aws-credentials | ||
args: [ '--allow-missing-credentials' ] | ||
stages: [commit] | ||
args: ["--allow-missing-credentials"] | ||
- repo: https://github.com/golangci/golangci-lint | ||
rev: v1.54.2 | ||
rev: v1.57.2 | ||
hooks: | ||
- id: golangci-lint | ||
stages: [commit] | ||
args: ["--timeout=10m"] | ||
- repo: https://github.com/TekWizely/pre-commit-golang | ||
rev: v1.0.0-rc.1 | ||
hooks: | ||
- id: go-imports | ||
stages: [commit] | ||
- repo: https://github.com/gitguardian/ggshield | ||
rev: v1.19.1 | ||
rev: v1.26.0 | ||
hooks: | ||
- id: ggshield | ||
language: python | ||
stages: [commit] | ||
args: [ 'secret', 'scan', 'pre-commit' ] | ||
args: ["secret", "scan", "pre-commit"] | ||
- repo: local | ||
hooks: | ||
- id: generate-secrets-loader | ||
name: generate-secrets-loader | ||
entry: ./secrets-loader.generator.sh | ||
language: script | ||
stages: [commit] | ||
- id: generate-catalog | ||
name: generate-catalog | ||
entry: ./catalog-info.generator.sh | ||
language: script | ||
pass_filenames: false | ||
stages: [commit] | ||
- id: commit-msg-spell-check | ||
name: commit-msg-spell-check | ||
entry: ./spell-check.sh | ||
language: script | ||
stages: ["commit-msg"] | ||
- id: append-ticket-id | ||
name: Append Ticket ID to Commit Message | ||
entry: ./append-ticket-id.sh | ||
language: script | ||
stages: [ commit-msg ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
# Function to get the current branch name | ||
get_current_branch() { | ||
git branch --show-current | ||
} | ||
|
||
# Function to get the commit message | ||
get_commit_message() { | ||
cat "$1" | ||
} | ||
|
||
# Function to write the commit message | ||
write_commit_message() { | ||
echo "$2" > "$1" | ||
} | ||
|
||
# Function to extract the ticket ID from the branch name | ||
extract_ticket_id() { | ||
echo "$1" | grep -o -E '(acq|da|data|dec|devop|ds|it|mlops|nerds|qa|sec|spe|ss)-[0-9]+' | tr '[:lower:]' '[:upper:]' | ||
} | ||
|
||
# Main script | ||
main() { | ||
if [ $# -eq 0 ]; then | ||
echo "commit message file not found, are you sure you set the stage for this hook to be in stages: [ commit-msg ]?" | ||
exit 1 | ||
fi | ||
|
||
commit_message_file="$1" | ||
branch_name=$(get_current_branch) | ||
ticket_id=$(extract_ticket_id "$branch_name") | ||
|
||
if [ -z "$ticket_id" ]; then | ||
echo "Warning: No ticket ID found in branch name '$branch_name'" | ||
exit 0 | ||
fi | ||
|
||
commit_message=$(get_commit_message "$commit_message_file") | ||
first_line=$(echo "$commit_message" | head -n 1) | ||
|
||
# Check if the first line already contains the ticket_id | ||
if ! echo "$first_line" | grep -qi "$ticket_id"; then | ||
first_line="$first_line [$ticket_id]" | ||
commit_message="$first_line$(echo "$commit_message" | tail -n +2)" | ||
write_commit_message "$commit_message_file" "$commit_message" | ||
fi | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.