-
Notifications
You must be signed in to change notification settings - Fork 1
Prepare the analysis engine for public use #4
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9375252
feat: package local insights analyzer
zroubalik fd26f67
ci: pin analyzer packaging actions
zroubalik ec14634
ci: isolate analyzer packaging check
zroubalik 70ced3b
ci: grant reusable checks required permissions
zroubalik 918ce64
fix: bound analyzer input
zroubalik 1cd6fef
fix: harden analyzer execution and release
zroubalik ee283ae
ci: document release workflow constraints
zroubalik 93480c8
fix: classify analyzer input read failures
zroubalik 08efeb1
Prepare analysis engine for public consumers
zroubalik 4b9e3c6
Pin public workflow dependencies
zroubalik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,110 @@ | ||
| # Reusable template workflow for backing up repositories to Google Cloud Storage | ||
| # SOC 2 Compliance: Complete git repository backup using bare mirror clone preserving all branches, tags, and history | ||
| # Required workflow-call secrets: GH_TOKEN (repository token) and GCP_SA_KEY (service account JSON key) | ||
|
|
||
| ############################################################################################# | ||
| # WARNING: | ||
| # UPDATE THIS FILE ONLY in kedify/github-meta/.github/workflows/repo-backup-template.yml | ||
| # | ||
| # Copy paste this file if needed to run from a public repo. | ||
| ############################################################################################ | ||
|
|
||
| name: "Repo Backup: backup repo to GCS" | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| bucket: | ||
| description: "GCS bucket name for backup storage (e.g. kedify-github-backups)" | ||
| required: true | ||
| type: string | ||
| secrets: | ||
| GH_TOKEN: | ||
| description: "Token used to clone the repository (map from caller's secrets.GITHUB_TOKEN or a PAT)" | ||
| required: true | ||
| GCP_SA_KEY: | ||
| description: "GCP Service Account JSON key for authentication" | ||
| required: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| backup: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Authenticate to Google Cloud | ||
| uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3 | ||
| with: | ||
| credentials_json: ${{ secrets.GCP_SA_KEY }} | ||
|
|
||
| - name: Setup Google Cloud SDK | ||
| uses: google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db # v3 | ||
|
|
||
| - name: Verify required tools | ||
| run: | | ||
| set -euo pipefail | ||
| echo "Verifying required tools..." | ||
| command -v git >/dev/null || { echo "git not found"; exit 1; } | ||
| command -v tar >/dev/null || { echo "tar not found"; exit 1; } | ||
| command -v gsutil >/dev/null || { echo "gsutil not found"; exit 1; } | ||
| echo "All required tools available" | ||
|
|
||
| - name: Create git mirror backup | ||
| run: | | ||
| set -euo pipefail | ||
| DATE=$(date +%F) | ||
| REPO_FULL="${{ github.repository }}" | ||
| SANITIZED_REPO="${REPO_FULL//\//_}" | ||
| ARCHIVE_NAME="${SANITIZED_REPO}-${DATE}-${GITHUB_RUN_ID}.tar.gz" | ||
| echo "ARCHIVE_NAME=${ARCHIVE_NAME}" >> "$GITHUB_ENV" | ||
|
|
||
| TEMP_DIR=$(mktemp -d) | ||
| trap 'rm -rf "$TEMP_DIR" 2>/dev/null || true' EXIT | ||
| cd "$TEMP_DIR" | ||
|
|
||
| git config --global url."https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/".insteadOf "https://github.com/" | ||
| git clone --mirror "https://github.com/${{ github.repository }}" repo.git | ||
|
|
||
| tar -czf "${ARCHIVE_NAME}" repo.git/ | ||
| mv "${ARCHIVE_NAME}" "${GITHUB_WORKSPACE}/${ARCHIVE_NAME}" | ||
| ls -lh "${GITHUB_WORKSPACE}/${ARCHIVE_NAME}" | ||
| echo "✓ Git mirror backup created" | ||
|
|
||
| - name: Upload backup to GCS (daily + monthly snapshot handling) | ||
| shell: bash | ||
| env: | ||
| ARCHIVE_NAME: ${{ env.ARCHIVE_NAME }} | ||
| run: | | ||
| set -euo pipefail | ||
| ORG="${{ github.repository_owner }}" | ||
| REPO_NAME=$(basename "${{ github.repository }}") | ||
| BUCKET="${{ inputs.bucket }}" | ||
|
|
||
| DAILY_PATH="gs://${BUCKET}/daily/${ORG}/${REPO_NAME}/" | ||
| MONTHLY_PATH="gs://${BUCKET}/monthly/${ORG}/${REPO_NAME}/" | ||
|
|
||
| echo "Uploading ${GITHUB_WORKSPACE}/${ARCHIVE_NAME} -> ${DAILY_PATH}" | ||
| gsutil cp "${GITHUB_WORKSPACE}/${ARCHIVE_NAME}" "${DAILY_PATH}" | ||
|
|
||
| if gsutil -q stat "${DAILY_PATH}${ARCHIVE_NAME}"; then | ||
| echo "✓ Daily backup uploaded: ${DAILY_PATH}${ARCHIVE_NAME}" | ||
| else | ||
| echo "✗ Failed to validate daily upload" | ||
| gsutil ls -l "${DAILY_PATH}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| DAY_OF_MONTH=$(date +%d) | ||
| if [ "$DAY_OF_MONTH" = "01" ]; then | ||
| echo "First of month — creating monthly snapshot copy -> ${MONTHLY_PATH}" | ||
| gsutil cp "${GITHUB_WORKSPACE}/${ARCHIVE_NAME}" "${MONTHLY_PATH}" | ||
|
|
||
| if gsutil -q stat "${MONTHLY_PATH}${ARCHIVE_NAME}"; then | ||
| echo "✓ Monthly snapshot uploaded: ${MONTHLY_PATH}${ARCHIVE_NAME}" | ||
| else | ||
| echo "✗ Failed to validate monthly snapshot upload" | ||
| gsutil ls -l "${MONTHLY_PATH}" | ||
| exit 1 | ||
| fi | ||
| fi |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.