Compare commits
57 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2aee68df73 | ||
|
|
2490ff12db | ||
|
|
e5a928d13d | ||
|
|
c9ce6e5f2b | ||
|
|
41fdf1fa9b | ||
|
|
a6fbab9110 | ||
|
|
9db021b9fa | ||
|
|
427ec7d0db | ||
|
|
bd24e8ffa0 | ||
|
|
efbb720adf | ||
|
|
91845516ad | ||
|
|
16f8a4f21f | ||
|
|
0ed6aa1276 | ||
|
|
926a9f858f | ||
|
|
54e7a01dfd | ||
|
|
c09b4b860a | ||
|
|
c1c97a4d3e | ||
|
|
fca761eb60 | ||
|
|
79718eb5d3 | ||
|
|
eac11e3221 | ||
|
|
554f9b8b3b | ||
|
|
4b19b20335 | ||
|
|
e456dc24af | ||
|
|
61766a3e9a | ||
|
|
46f7d871e0 | ||
|
|
fae8e2391a | ||
|
|
ee18665ef6 | ||
|
|
271501cafb | ||
|
|
4e1628177d | ||
|
|
f12ff2d395 | ||
|
|
88ed99b7fc | ||
|
|
51d86ab31b | ||
|
|
43849834d3 | ||
|
|
158704ce57 | ||
|
|
4d2248a6b3 | ||
|
|
83e5e27434 | ||
|
|
a4eb3de63a | ||
|
|
81c7700e22 | ||
|
|
5225763586 | ||
|
|
e76de4495e | ||
|
|
79c2498e4a | ||
|
|
4587a3f7c4 | ||
|
|
7779ba8e29 | ||
|
|
beb40ea877 | ||
|
|
90260b0efa | ||
|
|
f6eb8b6315 | ||
|
|
bfe846c9b2 | ||
|
|
1fbd64e412 | ||
|
|
60d2d0c243 | ||
|
|
21967e6a8b | ||
|
|
21bab00845 | ||
|
|
43623ff9fa | ||
|
|
0316d2ecc0 | ||
|
|
014680f18e | ||
|
|
7a2e073e16 | ||
|
|
f90d55af8a | ||
|
|
14fab87017 |
65
.github/unused/sh/trigger.sh
vendored
65
.github/unused/sh/trigger.sh
vendored
@ -1,65 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
curl -L \
|
|
||||||
-X POST \
|
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
-H "Authorization: Bearer <YOUR-TOKEN>"\
|
|
||||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
|
||||||
https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/dispatches \
|
|
||||||
-d '{"ref":"main","inputs":{"image":"${{ inputs.image }}","tag":"${{ inputs.tag }}"}}';
|
|
||||||
|
|
||||||
repo2.hub.gmetri.io/dt-api
|
|
||||||
main-fda468af
|
|
||||||
|
|
||||||
Token (DUMMY): e139b1c73bfae1b7748961c9f9a381bd3cca0633
|
|
||||||
|
|
||||||
|
|
||||||
https://git.gmetri.io/gmetrivr/cs-dt/actions/run?workflow=update-repo-version.yml&actor=0&status=
|
|
||||||
|
|
||||||
curl -X 'POST' \
|
|
||||||
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues' \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d '{
|
|
||||||
"assignee": "bot-build",
|
|
||||||
"body": "{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-fda468af\"}",
|
|
||||||
"closed": false,
|
|
||||||
"title": "cs-dt package for repo2.hub.gmetri.io/dt-api:main-fda468af"
|
|
||||||
}'
|
|
||||||
|
|
||||||
curl -X 'POST' \
|
|
||||||
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues/1/comments' \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
|
|
||||||
-d '{
|
|
||||||
"body": "{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-fda468af\"}"
|
|
||||||
}'
|
|
||||||
|
|
||||||
curl -X 'POST' \
|
|
||||||
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues/1/comments' \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d '{
|
|
||||||
"body": "{\"image\":\"repo2.hub.gmetri.io\/dt-api\",\"tag\":\"main-255c2f30\"}"
|
|
||||||
}'
|
|
||||||
|
|
||||||
ISSUE_COMMENT_STRING=`echo '{ "image": "repo2.hub.gmetri.io/dt-api", "tag": "main-255c2f30" }' | jq tostring`
|
|
||||||
API_JSON_BODY=`echo '{"body": '$ISSUE_COMMENT_STRING' }' | jq -r tostring`
|
|
||||||
# {"body":"{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-255c2f30\"}"}
|
|
||||||
|
|
||||||
curl -X 'POST' \
|
|
||||||
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues/1/comments' \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d $API_JSON_BODY
|
|
||||||
|
|
||||||
curl -X 'POST' \
|
|
||||||
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues/1/comments' \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d '{"body":"{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-255c2f30\"}"}'
|
|
||||||
71
.github/workflows/base-build-image-gcp.yml
vendored
Normal file
71
.github/workflows/base-build-image-gcp.yml
vendored
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
name: Build base images (Generally from basin repo)
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
image_tag:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
fail_on_scan:
|
||||||
|
default: true
|
||||||
|
type: boolean
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker-build-and-push:
|
||||||
|
|
||||||
|
runs-on: ubuntu-22.04 #ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- id: get-id
|
||||||
|
name: Get a unique tag for this build
|
||||||
|
run: |
|
||||||
|
echo "DOCKER_IMAGE=${{ vars.GCP_DOCKER_REGISTRY }}/${{ github.repository }}:${{ inputs.image_tag }}" >> "$GITHUB_OUTPUT";
|
||||||
|
|
||||||
|
- name: Print image name
|
||||||
|
run: |
|
||||||
|
echo "${{ steps.get-id.outputs.DOCKER_IMAGE }}";
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# ✅ 1) Auth to GCP (this is where your SA key is used)
|
||||||
|
- name: Auth to GCP
|
||||||
|
uses: google-github-actions/auth@v2
|
||||||
|
with:
|
||||||
|
# using your existing secret that contains the SA JSON
|
||||||
|
credentials_json: ${{ secrets.GCP_SA_KEY }}
|
||||||
|
|
||||||
|
# ✅ 2) Install gcloud (no creds here)
|
||||||
|
- name: Set up gcloud
|
||||||
|
uses: google-github-actions/setup-gcloud@v2
|
||||||
|
with:
|
||||||
|
project_id: ${{ vars.GCP_PROJECT_ID }}
|
||||||
|
export_default_credentials: true
|
||||||
|
|
||||||
|
- name: Configure Docker for GAR
|
||||||
|
run: |
|
||||||
|
gcloud auth configure-docker ${{vars.GCP_REGION}}-docker.pkg.dev
|
||||||
|
|
||||||
|
- name: Build and push the Docker image
|
||||||
|
run: |
|
||||||
|
docker build \
|
||||||
|
--file context/Dockerfile \
|
||||||
|
--tag ${{ steps.get-id.outputs.DOCKER_IMAGE }} \
|
||||||
|
./context;
|
||||||
|
|
||||||
|
- name: Container details
|
||||||
|
run: |
|
||||||
|
IMAGE_SIZE=`docker inspect -f "{{ .Size }}" ${{ steps.get-id.outputs.DOCKER_IMAGE }} | numfmt --to=si`;
|
||||||
|
echo "$IMAGE_SIZE container ${{ steps.get-id.outputs.DOCKER_IMAGE }}";
|
||||||
|
|
||||||
|
# - name: Scan Docker Image for vulnerabilities with Grype
|
||||||
|
# uses: anchore/scan-action@v6
|
||||||
|
# with:
|
||||||
|
# image: ${{ steps.get-id.outputs.DOCKER_IMAGE }}
|
||||||
|
# cache-db: true #Cache Grype DB in Github Actions
|
||||||
|
# output-format: table
|
||||||
|
# only-fixed: true
|
||||||
|
# severity-cutoff: critical
|
||||||
|
# fail-build: ${{ inputs.fail_on_scan }}
|
||||||
|
|
||||||
|
- name: Push the container image
|
||||||
|
run: docker push ${{ steps.get-id.outputs.DOCKER_IMAGE }}
|
||||||
5
.github/workflows/base-build-image.yml
vendored
5
.github/workflows/base-build-image.yml
vendored
@ -6,6 +6,9 @@ on:
|
|||||||
image_tag:
|
image_tag:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
fail_on_scan:
|
||||||
|
default: true
|
||||||
|
type: boolean
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker-build-and-push:
|
docker-build-and-push:
|
||||||
@ -52,7 +55,7 @@ jobs:
|
|||||||
output-format: table
|
output-format: table
|
||||||
only-fixed: true
|
only-fixed: true
|
||||||
severity-cutoff: critical
|
severity-cutoff: critical
|
||||||
fail-build: true
|
fail-build: ${{ inputs.fail_on_scan }}
|
||||||
|
|
||||||
- name: Push the container image
|
- name: Push the container image
|
||||||
run: docker push ${{ steps.get-id.outputs.DOCKER_IMAGE }}
|
run: docker push ${{ steps.get-id.outputs.DOCKER_IMAGE }}
|
||||||
|
|||||||
54
.github/workflows/deploy-cs.yml
vendored
54
.github/workflows/deploy-cs.yml
vendored
@ -1,54 +0,0 @@
|
|||||||
name: Reusable container push workflow
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
inputs:
|
|
||||||
deploy_repo:
|
|
||||||
description: 'The cs repo that contains this image'
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
|
|
||||||
env:
|
|
||||||
REPO: ${{ github.repository }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
trigger-cs-job:
|
|
||||||
permissions:
|
|
||||||
issues: write
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
steps:
|
|
||||||
- id: get-id
|
|
||||||
name: Get a unique tag for this build
|
|
||||||
run: |
|
|
||||||
SHA=${{ github.sha }}; BRANCH_NAME=${{ github.base_ref || github.ref_name }};
|
|
||||||
BUILD_ID=$BRANCH_NAME-${SHA:0:8};
|
|
||||||
DOCKER_BASE=${{ vars.docker_repo2_registry }}/$REPO
|
|
||||||
DOCKER_IMAGE=$DOCKER_BASE:$BUILD_ID;
|
|
||||||
echo "BUILD_ID=$BUILD_ID" >> "$GITHUB_OUTPUT";
|
|
||||||
echo "DOCKER_BASE=$DOCKER_BASE" >> "$GITHUB_OUTPUT";
|
|
||||||
echo "DOCKER_IMAGE=$DOCKER_IMAGE" >> "$GITHUB_OUTPUT";
|
|
||||||
|
|
||||||
- name: Print build id and image name
|
|
||||||
run: |
|
|
||||||
echo "BUILD_ID: ${{ steps.get-id.outputs.BUILD_ID }}";
|
|
||||||
echo "DOCKER_BASE: ${{ steps.get-id.outputs.DOCKER_BASE }}";
|
|
||||||
echo "DOCKER_IMAGE: ${{ steps.get-id.outputs.DOCKER_IMAGE }}";
|
|
||||||
|
|
||||||
- name: Push image name and tag to cs repo's issue#1
|
|
||||||
run: |
|
|
||||||
ISSUE_COMMENT_STRING=`echo "{ \"image\": \"${{ steps.get-id.outputs.DOCKER_BASE }}\", \"tag\": \"${{ steps.get-id.outputs.BUILD_ID }}\" }" | jq tostring`
|
|
||||||
echo ISSUE_COMMENT_STRING: $ISSUE_COMMENT_STRING
|
|
||||||
|
|
||||||
API_JSON_BODY=`echo '{"body": '$ISSUE_COMMENT_STRING' }' | jq -r tostring`
|
|
||||||
echo API_JSON_BODY: $API_JSON_BODY
|
|
||||||
# {"body":"{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-255c2f30\"}"}
|
|
||||||
|
|
||||||
set +x
|
|
||||||
curl -X 'POST' \
|
|
||||||
'${{ github.api_url }}/repos/${{ inputs.deploy_repo }}/issues/1/comments' \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H 'Authorization: token ${{ secrets.bot_build_issues_token }}' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d $API_JSON_BODY
|
|
||||||
set +x
|
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
name: Build base images (Generally from basin repo)
|
name: Build base images from code repos
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
@ -44,6 +44,9 @@ jobs:
|
|||||||
IMAGE_SIZE=`docker inspect -f "{{ .Size }}" ${{ steps.get-id.outputs.DOCKER_IMAGE }} | numfmt --to=si`;
|
IMAGE_SIZE=`docker inspect -f "{{ .Size }}" ${{ steps.get-id.outputs.DOCKER_IMAGE }} | numfmt --to=si`;
|
||||||
echo "$IMAGE_SIZE container ${{ steps.get-id.outputs.DOCKER_IMAGE }}";
|
echo "$IMAGE_SIZE container ${{ steps.get-id.outputs.DOCKER_IMAGE }}";
|
||||||
|
|
||||||
|
- name: Push the container image
|
||||||
|
run: docker push ${{ steps.get-id.outputs.DOCKER_IMAGE }}
|
||||||
|
|
||||||
- name: Scan Docker Image for vulnerabilities with Grype
|
- name: Scan Docker Image for vulnerabilities with Grype
|
||||||
uses: anchore/scan-action@v6
|
uses: anchore/scan-action@v6
|
||||||
with:
|
with:
|
||||||
@ -54,5 +57,3 @@ jobs:
|
|||||||
severity-cutoff: critical
|
severity-cutoff: critical
|
||||||
fail-build: true
|
fail-build: true
|
||||||
|
|
||||||
- name: Push the container image
|
|
||||||
run: docker push ${{ steps.get-id.outputs.DOCKER_IMAGE }}
|
|
||||||
36
.github/workflows/push-code-scan.yml
vendored
Normal file
36
.github/workflows/push-code-scan.yml
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
name: Vulnerability Scan
|
||||||
|
# Secrets can only viewed in "push" events. Not pull_request events.
|
||||||
|
# That's why this step needs to be called on push, and not on pull_request (to read npm password).
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
push-container-scan:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 22
|
||||||
|
registry-url: ${{ vars.NPM_REGISTRY }}
|
||||||
|
token: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
|
- name: Install npm dependencies
|
||||||
|
run: |
|
||||||
|
npm install -g pnpm
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
- name: Scan container image for vulnerabilities with grype
|
||||||
|
uses: anchore/scan-action@v6
|
||||||
|
with:
|
||||||
|
path: "."
|
||||||
|
cache-db: true #Cache Grype DB in Github Actions
|
||||||
|
output-format: table
|
||||||
|
only-fixed: true
|
||||||
|
severity-cutoff: critical
|
||||||
|
fail-build: true
|
||||||
30
.github/workflows/push-code-test.yml
vendored
Normal file
30
.github/workflows/push-code-test.yml
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
name: Run Tests
|
||||||
|
# Secrets can only viewed in "push" events. Not pull_request events.
|
||||||
|
# That's why this step needs to be called on push, and not on pull_request (to read npm password).
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
push-container-scan:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 22
|
||||||
|
registry-url: ${{ vars.NPM_REGISTRY }}
|
||||||
|
token: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
|
- name: Install npm dependencies
|
||||||
|
run: |
|
||||||
|
npm install -g pnpm
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
run: |
|
||||||
|
pnpm test
|
||||||
63
.github/workflows/push-container-gcp.yml
vendored
Normal file
63
.github/workflows/push-container-gcp.yml
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
name: Reusable container push workflow
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
env:
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
push-container:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- id: get-id
|
||||||
|
name: Get a unique tag for this build
|
||||||
|
run: |
|
||||||
|
SHA=${{ github.sha }}; BRANCH_NAME=${{ github.base_ref || github.ref_name }};
|
||||||
|
BUILD_ID=$BRANCH_NAME-${SHA:0:8};
|
||||||
|
DOCKER_IMAGE="${{vars.GCP_DOCKER_REGISTRY}}/$REPO:$BUILD_ID"
|
||||||
|
echo "BUILD_ID=$BUILD_ID" >> "$GITHUB_OUTPUT";
|
||||||
|
echo "DOCKER_IMAGE=$DOCKER_IMAGE" >> "$GITHUB_OUTPUT";
|
||||||
|
|
||||||
|
- name: Print build id and image name
|
||||||
|
run: |
|
||||||
|
echo "BUILD_ID: ${{ steps.get-id.outputs.BUILD_ID }}";
|
||||||
|
echo "DOCKER_IMAGE: ${{ steps.get-id.outputs.DOCKER_IMAGE }}";
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# ✅ 1) Auth to GCP (this is where your SA key is used)
|
||||||
|
- name: Auth to GCP
|
||||||
|
uses: google-github-actions/auth@v2
|
||||||
|
with:
|
||||||
|
# using your existing secret that contains the SA JSON
|
||||||
|
credentials_json: ${{ secrets.GCP_SA_KEY }}
|
||||||
|
|
||||||
|
# ✅ 2) Install gcloud (no creds here)
|
||||||
|
- name: Set up gcloud
|
||||||
|
uses: google-github-actions/setup-gcloud@v2
|
||||||
|
with:
|
||||||
|
project_id: ${{ vars.GCP_PROJECT_ID }}
|
||||||
|
export_default_credentials: true
|
||||||
|
|
||||||
|
- name: Configure Docker for GAR
|
||||||
|
run: |
|
||||||
|
gcloud auth configure-docker ${{vars.GCP_REGION}}-docker.pkg.dev
|
||||||
|
|
||||||
|
- name: Build the container image
|
||||||
|
run: |
|
||||||
|
docker build \
|
||||||
|
--build-arg BUILD_STEP=container \
|
||||||
|
--build-arg PUBLIC_BUILD_VERSION=${{ steps.get-id.outputs.BUILD_ID }} \
|
||||||
|
--file fab/d/actions-build.Dockerfile \
|
||||||
|
--tag ${{ steps.get-id.outputs.DOCKER_IMAGE }} \
|
||||||
|
.;
|
||||||
|
|
||||||
|
- name: Container details
|
||||||
|
run: |
|
||||||
|
IMAGE_SIZE=`docker inspect -f "{{ .Size }}" ${{ steps.get-id.outputs.DOCKER_IMAGE }} | numfmt --to=si`;
|
||||||
|
echo "$IMAGE_SIZE container ${{ steps.get-id.outputs.DOCKER_IMAGE }}";
|
||||||
|
|
||||||
|
- name: Push the container image
|
||||||
|
run: docker push ${{ steps.get-id.outputs.DOCKER_IMAGE }}
|
||||||
@ -10,7 +10,7 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
image-vulnerability-scan:
|
push-container-scan:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@ -38,9 +38,10 @@ jobs:
|
|||||||
password: ${{ secrets.docker_repo2_password }}
|
password: ${{ secrets.docker_repo2_password }}
|
||||||
|
|
||||||
- name: Build the container image (quick, without PUBLIC_BUILD_VERSION)
|
- name: Build the container image (quick, without PUBLIC_BUILD_VERSION)
|
||||||
# Commenting this from docker build for speed: --build-arg PUBLIC_BUILD_VERSION=$BUILD_ID \
|
|
||||||
run: |
|
run: |
|
||||||
docker build \
|
docker build \
|
||||||
|
--build-arg BUILD_STEP=container \
|
||||||
|
--build-arg PUBLIC_BUILD_VERSION=${{ steps.get-id.outputs.BUILD_ID }} \
|
||||||
--file fab/d/actions-build.Dockerfile \
|
--file fab/d/actions-build.Dockerfile \
|
||||||
--tag ${{ steps.get-id.outputs.DOCKER_IMAGE }} \
|
--tag ${{ steps.get-id.outputs.DOCKER_IMAGE }} \
|
||||||
.;
|
.;
|
||||||
5
.github/workflows/push-container.yml
vendored
5
.github/workflows/push-container.yml
vendored
@ -8,7 +8,7 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
container-build-and-push:
|
push-container:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- id: get-id
|
- id: get-id
|
||||||
@ -37,6 +37,7 @@ jobs:
|
|||||||
- name: Build the container image
|
- name: Build the container image
|
||||||
run: |
|
run: |
|
||||||
docker build \
|
docker build \
|
||||||
|
--build-arg BUILD_STEP=container \
|
||||||
--build-arg PUBLIC_BUILD_VERSION=${{ steps.get-id.outputs.BUILD_ID }} \
|
--build-arg PUBLIC_BUILD_VERSION=${{ steps.get-id.outputs.BUILD_ID }} \
|
||||||
--file fab/d/actions-build.Dockerfile \
|
--file fab/d/actions-build.Dockerfile \
|
||||||
--tag ${{ steps.get-id.outputs.DOCKER_IMAGE }} \
|
--tag ${{ steps.get-id.outputs.DOCKER_IMAGE }} \
|
||||||
@ -48,4 +49,4 @@ jobs:
|
|||||||
echo "$IMAGE_SIZE container ${{ steps.get-id.outputs.DOCKER_IMAGE }}";
|
echo "$IMAGE_SIZE container ${{ steps.get-id.outputs.DOCKER_IMAGE }}";
|
||||||
|
|
||||||
- name: Push the container image
|
- name: Push the container image
|
||||||
run: docker push ${{ steps.get-id.outputs.DOCKER_IMAGE }}
|
run: docker push ${{ steps.get-id.outputs.DOCKER_IMAGE }}
|
||||||
84
.github/workflows/push-npm-from-container.yml
vendored
Normal file
84
.github/workflows/push-npm-from-container.yml
vendored
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
name: Reusable container push workflow
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
env:
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
push-npm:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
permissions:
|
||||||
|
# Give the default GITHUB_TOKEN write permission to commit and push the
|
||||||
|
# added or changed files to the repository.
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 22
|
||||||
|
registry-url: ${{ vars.NPM_REGISTRY }}
|
||||||
|
token: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
|
- run: npm install -g pnpm
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- id: get-id
|
||||||
|
name: Get a unique tag for this build
|
||||||
|
run: |
|
||||||
|
SHA=${{ github.sha }}; BRANCH_NAME=${{ github.base_ref || github.ref_name }};
|
||||||
|
BUILD_ID=$BRANCH_NAME-${SHA:0:8};
|
||||||
|
DOCKER_IMAGE=${{ vars.docker_repo2_registry }}/$REPO:$BUILD_ID;
|
||||||
|
echo "BUILD_ID=$BUILD_ID" >> "$GITHUB_OUTPUT";
|
||||||
|
echo "DOCKER_IMAGE=$DOCKER_IMAGE" >> "$GITHUB_OUTPUT";
|
||||||
|
|
||||||
|
- name: Print build id and image name
|
||||||
|
run: |
|
||||||
|
echo "BUILD_ID: ${{ steps.get-id.outputs.BUILD_ID }}";
|
||||||
|
echo "DOCKER_IMAGE: ${{ steps.get-id.outputs.DOCKER_IMAGE }}";
|
||||||
|
|
||||||
|
- name: Login to docker container registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ vars.docker_repo2_registry }}
|
||||||
|
username: ${{ secrets.docker_repo2_username }}
|
||||||
|
password: ${{ secrets.docker_repo2_password }}
|
||||||
|
|
||||||
|
- name: Build the container image for npm build, with dependencies
|
||||||
|
run: |
|
||||||
|
docker build \
|
||||||
|
--build-arg BUILD_STEP=bundle \
|
||||||
|
--build-arg PUBLIC_BUILD_VERSION=${{ steps.get-id.outputs.BUILD_ID }} \
|
||||||
|
--file fab/d/actions-build.Dockerfile \
|
||||||
|
--tag ${{ steps.get-id.outputs.DOCKER_IMAGE }} \
|
||||||
|
.;
|
||||||
|
|
||||||
|
- name: Extract lib files
|
||||||
|
run: |
|
||||||
|
image=${{ steps.get-id.outputs.DOCKER_IMAGE }}
|
||||||
|
source_path=/src/lib
|
||||||
|
destination_path=lib
|
||||||
|
|
||||||
|
container_id=$(docker create "$image" "pnpm build_npm")
|
||||||
|
docker container start -a $container_id
|
||||||
|
|
||||||
|
docker cp "$container_id:$source_path" "$destination_path"
|
||||||
|
docker rm "$container_id"
|
||||||
|
|
||||||
|
- name: Increment package version and push
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
git config --global user.name 'bot-build'
|
||||||
|
git config --global user.email 'techbots+build@gmetri.com'
|
||||||
|
|
||||||
|
export N=`node -p require\(\'./package.json\'\).name` && echo $N
|
||||||
|
pnpm version patch --message "v%s: $N [CI SKIP]"
|
||||||
|
|
||||||
|
npm publish
|
||||||
|
|
||||||
|
git push origin
|
||||||
|
git push --tags origin
|
||||||
16
.github/workflows/push-npm.yml
vendored
16
.github/workflows/push-npm.yml
vendored
@ -8,7 +8,7 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
npm-push:
|
push-npm:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
permissions:
|
permissions:
|
||||||
# Give the default GITHUB_TOKEN write permission to commit and push the
|
# Give the default GITHUB_TOKEN write permission to commit and push the
|
||||||
@ -16,20 +16,20 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 22
|
node-version: 22
|
||||||
registry-url: ${{ vars.NPM_REGISTRY }}
|
registry-url: ${{ vars.NPM_REGISTRY }}
|
||||||
token: ${{ secrets.NPM_TOKEN }}
|
token: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
- name: Install npm dependencies
|
- run: npm install -g pnpm
|
||||||
run: |
|
|
||||||
npm install -g pnpm
|
|
||||||
pnpm install
|
|
||||||
|
|
||||||
- run: pnpm build
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install npm dependencies and build
|
||||||
|
run: |
|
||||||
|
pnpm install
|
||||||
|
pnpm build_npm
|
||||||
|
|
||||||
- name: Increment package version and push
|
- name: Increment package version and push
|
||||||
env:
|
env:
|
||||||
|
|||||||
86
.github/workflows/push-s3-gcp.yml
vendored
Normal file
86
.github/workflows/push-s3-gcp.yml
vendored
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
name: Docker Image CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
# Org Secrets are available on push event. Not pull_request event.
|
||||||
|
|
||||||
|
env:
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
|
REPO_SHORT_NAME: ${{ github.event.repository.name }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
push-s3:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- id: get-id
|
||||||
|
name: Get a unique tag for this build
|
||||||
|
run: |
|
||||||
|
SHA=${{ github.sha }}; BRANCH_NAME=${{ github.base_ref || github.ref_name }};
|
||||||
|
BUILD_ID=$BRANCH_NAME-${SHA:0:8};
|
||||||
|
DOCKER_IMAGE=${{ vars.GCP_DOCKER_REGISTRY }}/$REPO:$BUILD_ID;
|
||||||
|
echo "BUILD_ID=$BUILD_ID" >> "$GITHUB_OUTPUT";
|
||||||
|
echo "DOCKER_IMAGE=$DOCKER_IMAGE" >> "$GITHUB_OUTPUT";
|
||||||
|
|
||||||
|
- name: Print build id and image name
|
||||||
|
run: |
|
||||||
|
echo "BUILD_ID: ${{ steps.get-id.outputs.BUILD_ID }}";
|
||||||
|
echo "DOCKER_IMAGE: ${{ steps.get-id.outputs.DOCKER_IMAGE }}";
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# ✅ 1) Auth to GCP (this is where your SA key is used)
|
||||||
|
- name: Auth to GCP
|
||||||
|
uses: google-github-actions/auth@v2
|
||||||
|
with:
|
||||||
|
# using your existing secret that contains the SA JSON
|
||||||
|
credentials_json: ${{ secrets.GCP_SA_KEY }}
|
||||||
|
|
||||||
|
# ✅ 2) Install gcloud (no creds here)
|
||||||
|
- name: Set up gcloud
|
||||||
|
uses: google-github-actions/setup-gcloud@v2
|
||||||
|
with:
|
||||||
|
project_id: ${{ vars.GCP_PROJECT_ID }}
|
||||||
|
export_default_credentials: true
|
||||||
|
|
||||||
|
- name: Configure Docker for GAR
|
||||||
|
run: |
|
||||||
|
gcloud auth configure-docker ${{vars.GCP_REGION}}-docker.pkg.dev
|
||||||
|
|
||||||
|
|
||||||
|
- name: Build the container image for bundle step
|
||||||
|
run: |
|
||||||
|
docker build \
|
||||||
|
--build-arg BUILD_STEP=bundle \
|
||||||
|
--build-arg PUBLIC_BUILD_VERSION=${{ steps.get-id.outputs.BUILD_ID }} \
|
||||||
|
--file fab/d/actions-build.Dockerfile \
|
||||||
|
--tag ${{ steps.get-id.outputs.DOCKER_IMAGE }} \
|
||||||
|
.;
|
||||||
|
|
||||||
|
- name: Extract cloud files
|
||||||
|
run: |
|
||||||
|
image=${{ steps.get-id.outputs.DOCKER_IMAGE }}
|
||||||
|
source_path=/cloud
|
||||||
|
destination_path=cloud
|
||||||
|
|
||||||
|
container_id=$(docker create "$image")
|
||||||
|
docker cp "$container_id:$source_path" "$destination_path"
|
||||||
|
docker rm "$container_id"
|
||||||
|
|
||||||
|
echo "Running: ls $destination_path"
|
||||||
|
ls $destination_path
|
||||||
|
|
||||||
|
- name: Upload cloud files
|
||||||
|
uses: https://git.gmetri.io/gmetribin/aws-cli-action@v1.0.0
|
||||||
|
env:
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
|
||||||
|
AWS_DEFAULT_REGION: ${{ vars.aws_default_region }}
|
||||||
|
with:
|
||||||
|
args: >
|
||||||
|
s3 cp \
|
||||||
|
--recursive \
|
||||||
|
--cache-control max-age=31536000\
|
||||||
|
--storage-class 'STANDARD_IA' \
|
||||||
|
cloud/ s3://${{ vars.aws_upload_bucket }}/${{ env.REPO_SHORT_NAME }}/${{ steps.get-id.outputs.BUILD_ID }}
|
||||||
5
.github/workflows/push-s3.yml
vendored
5
.github/workflows/push-s3.yml
vendored
@ -11,7 +11,7 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
s3-push:
|
push-s3:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- id: get-id
|
- id: get-id
|
||||||
@ -37,9 +37,10 @@ jobs:
|
|||||||
username: ${{ secrets.docker_repo2_username }}
|
username: ${{ secrets.docker_repo2_username }}
|
||||||
password: ${{ secrets.docker_repo2_password }}
|
password: ${{ secrets.docker_repo2_password }}
|
||||||
|
|
||||||
- name: Build the container image
|
- name: Build the container image for bundle step
|
||||||
run: |
|
run: |
|
||||||
docker build \
|
docker build \
|
||||||
|
--build-arg BUILD_STEP=bundle \
|
||||||
--build-arg PUBLIC_BUILD_VERSION=${{ steps.get-id.outputs.BUILD_ID }} \
|
--build-arg PUBLIC_BUILD_VERSION=${{ steps.get-id.outputs.BUILD_ID }} \
|
||||||
--file fab/d/actions-build.Dockerfile \
|
--file fab/d/actions-build.Dockerfile \
|
||||||
--tag ${{ steps.get-id.outputs.DOCKER_IMAGE }} \
|
--tag ${{ steps.get-id.outputs.DOCKER_IMAGE }} \
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -129,4 +129,4 @@ dist
|
|||||||
.yarn/build-state.yml
|
.yarn/build-state.yml
|
||||||
.yarn/install-state.gz
|
.yarn/install-state.gz
|
||||||
.pnp.*
|
.pnp.*
|
||||||
|
.idea/
|
||||||
@ -51,22 +51,6 @@ https://github.com/orgs/community/discussions/26625#discussioncomment-3252582
|
|||||||
|
|
||||||
https://anchorecommunity.discourse.group/t/how-to-act-on-go-module-vulnerabilities/186/2
|
https://anchorecommunity.discourse.group/t/how-to-act-on-go-module-vulnerabilities/186/2
|
||||||
|
|
||||||
Within the image:
|
|
||||||
```bash
|
|
||||||
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sudo sh -s -- -b ./bin
|
|
||||||
|
|
||||||
#To check vulnerabilities
|
|
||||||
grypd .
|
|
||||||
#To save detailed output
|
|
||||||
grype $MY_IMAGE -o json > vuln.json
|
|
||||||
#OR
|
|
||||||
grype . -o json > vuln.json
|
|
||||||
|
|
||||||
#To explain the issue:
|
|
||||||
cat vuln.json | grype explain --id CVE-2023-24537
|
|
||||||
cat vuln2.json | grype explain --id CVE-2023-45853
|
|
||||||
```
|
|
||||||
|
|
||||||
## Getting the word "main" (branch name) during builds
|
## Getting the word "main" (branch name) during builds
|
||||||
|
|
||||||
If the build (was triggered by) is a merge of a pull request, GITHUB_BASE_REF will contain main.
|
If the build (was triggered by) is a merge of a pull request, GITHUB_BASE_REF will contain main.
|
||||||
12
README-build-notes.md
Normal file
12
README-build-notes.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
> https://git.gmetri.io/gmetribin/build-tools/src/branch/main/.github/README-build-notes.md
|
||||||
|
|
||||||
|
1) npm build -> push to npm `pnpm build_npm`
|
||||||
|
2) webpack build -> push assets to s3 Builds the docker. (Inside the docker `pnpm build`)
|
||||||
|
3) push docker with code that executes on. Docker image decides the start CMD. (Generally `pnpm start`)
|
||||||
|
4) image scan (dependent on docker build)
|
||||||
|
5) pushes the docker version to the cs-* repo
|
||||||
|
|
||||||
|
### 3 Push Docker
|
||||||
|
* Docker will be built with the Dockerfile `./fab/d/actions-build.Dockerfile`
|
||||||
|
* Context will be `.`
|
||||||
|
* env var `PUBLIC_BUILD_VERSION` will be passed as an env var Docker builds.
|
||||||
Loading…
x
Reference in New Issue
Block a user