Skip to content

Commit 01b669c

Browse files
author
Komal Yadav
committed
Add exit gate
updated updated updated updated updated
1 parent 3c2ce71 commit 01b669c

File tree

2 files changed

+103
-22
lines changed

2 files changed

+103
-22
lines changed

.github/workflows/build-and-deploy.yml

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright © 2022 Cask Data, Inc.
1+
# Copyright © 2025 Cask Data, Inc.
22
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
33
# use this file except in compliance with the License. You may obtain a copy of
44
# the License at
@@ -30,10 +30,7 @@ jobs:
3030
uses: 'google-github-actions/get-secretmanager-secrets@v0'
3131
with:
3232
secrets: |-
33-
CDAP_OSSRH_USERNAME:cdapio-github-builds/CDAP_OSSRH_USERNAME
34-
CDAP_OSSRH_PASSWORD:cdapio-github-builds/CDAP_OSSRH_PASSWORD
35-
CDAP_GPG_PASSPHRASE:cdapio-github-builds/CDAP_GPG_PASSPHRASE
36-
CDAP_GPG_PRIVATE_KEY:cdapio-github-builds/CDAP_GPG_PRIVATE_KEY
33+
secure_publish_bucket:cdapio-github-builds/publish_bucket
3734
3835
- name: Recursively Checkout Repository
3936
uses: actions/checkout@v3
@@ -50,22 +47,15 @@ jobs:
5047
restore-keys: |
5148
${{ runner.os }}-maven-${{ github.workflow }}
5249
53-
- name: Set up GPG conf
50+
- name: 'Submit Build to Google Cloud Build'
51+
id: gcb
52+
working-directory: netty-http
5453
run: |
55-
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
56-
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
57-
58-
- name: Import GPG key
54+
- name: Submit Build to GCB
55+
id: gcb
56+
working-directory: cdap-e2e-tests
5957
run: |
60-
echo "$GPG_PRIVATE_KEY" > private.key
61-
gpg --import --batch private.key
62-
env:
63-
GPG_PRIVATE_KEY: ${{ steps.secrets.outputs.CDAP_GPG_PRIVATE_KEY }}
64-
65-
- name: Deploy Maven
66-
working-directory: netty
67-
run: mvn -U clean deploy -P release -Dgpg.passphrase=$CDAP_GPG_PASSPHRASE
68-
env:
69-
CDAP_OSSRH_USERNAME: ${{ steps.secrets.outputs.CDAP_OSSRH_USERNAME }}
70-
CDAP_OSSRH_PASSWORD: ${{ steps.secrets.outputs.CDAP_OSSRH_PASSWORD }}
71-
CDAP_GPG_PASSPHRASE: ${{ steps.secrets.outputs.CDAP_GPG_PASSPHRASE }}
58+
gcloud builds submit . \
59+
--config=cloudbuild-release.yaml \
60+
--project='cdapio-github-builds' \
61+
--substitutions="_ARTIFACT_ID='netty-http',_SECURE_PUBLISH_BUCKET_NAME=${{ steps.gcp_secrets.outputs.secure_publish_bucket }}"

cloudbuild.yaml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Copyright © 2025 Cask Data, Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
3+
# use this file except in compliance with the License. You may obtain a copy of
4+
# the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
9+
# License for the specific language governing permissions and limitations under
10+
# the License.
11+
12+
# cloudbuild.yaml
13+
steps:
14+
- name: 'maven:3.8-jdk-8' # Specify a Maven image
15+
id: maven-package
16+
entrypoint: 'mvn'
17+
args:
18+
- -B
19+
- -U
20+
- clean
21+
- package
22+
- -DskipTests
23+
24+
- name: 'anchore/syft:v1.5.0'
25+
id: generate-sbom
26+
args:
27+
- 'packages'
28+
- '-o'
29+
- 'spdx-json=/workspace/attestations/project-sbom.spdx.json'
30+
- '.'
31+
waitFor: ['maven-package']
32+
33+
- name: 'bash'
34+
id: stage-artifacts
35+
entrypoint: 'bash'
36+
args:
37+
- '-c'
38+
- |
39+
set -e
40+
mkdir -p /workspace/staging
41+
42+
# Copy Maven artifacts
43+
echo "Copying Maven artifacts..."
44+
find target -name "*.jar" -exec cp {} /workspace/staging/ \;
45+
find target -name "*.pom" -exec cp {} /workspace/staging/ \;
46+
# Add other artifact types if necessary (e.g., -sources.jar, -javadoc.jar)
47+
48+
# Copy SBOM
49+
echo "Copying SBOM..."
50+
cp /workspace/attestations/project-sbom.spdx.json /workspace/staging/
51+
52+
# List staged files for debugging
53+
echo "Staged files:"
54+
ls -l /workspace/staging
55+
waitFor: ['generate-sbom']
56+
57+
- name: 'bash'
58+
id: create-manifest
59+
entrypoint: 'bash'
60+
args:
61+
- '-c'
62+
- |
63+
set -e
64+
echo "Creating manifest.json..."
65+
cd /workspace/staging
66+
printf '{\n "artifacts": [\n' > manifest.json
67+
find . -maxdepth 1 -type f ! -name "manifest.json" | sed 's|./||' | sed 's/.*/ "&",/' >> manifest.json
68+
# Remove trailing comma from the last line
69+
sed -i '$ s/,$//' manifest.json
70+
printf '\n ]\n}\n' >> manifest.json
71+
72+
echo "Generated manifest.json:"
73+
cat manifest.json
74+
cd /workspace
75+
waitFor: ['stage-artifacts']
76+
77+
- name: 'gcr.io/cloud-builders/gsutil'
78+
id: upload-to-staging
79+
args:
80+
- '-m'
81+
- 'cp'
82+
- '-r'
83+
- '/workspace/staging/*'
84+
- 'gs://${_SECURE_PUBLISH_BUCKET_NAME}/${_ARTIFACT_ID}/${BUILD_ID}/'
85+
waitFor: ['create-manifest']
86+
87+
options:
88+
requestedVerifyOption: VERIFIED
89+
machineType: 'E2_HIGHCPU_32'
90+
91+

0 commit comments

Comments
 (0)