Skip to content

Commit 3ef252c

Browse files
author
Komal Yadav
committed
Add exit gate
updated updated updated updated
1 parent 15aeb92 commit 3ef252c

File tree

2 files changed

+104
-23
lines changed

2 files changed

+104
-23
lines changed

.github/workflows/deploy.yml

Lines changed: 9 additions & 23 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: Checkout Repository
3936
uses: actions/checkout@v4
@@ -49,23 +46,12 @@ jobs:
4946
restore-keys: |
5047
${{ runner.os }}-maven-cdap-e2e-framework
5148
52-
- name: Import GPG key
49+
- name: Submit Build to GCB
50+
id: gcb
51+
working-directory: cdap-e2e-tests
5352
run: |
54-
echo "$GPG_PRIVATE_KEY" > private.key
55-
gpg --import --batch private.key
56-
env:
57-
GPG_PRIVATE_KEY: ${{ steps.secrets.outputs.CDAP_GPG_PRIVATE_KEY }}
53+
gcloud builds submit . \
54+
--config=cloudbuild-release.yaml \
55+
--project='cdapio-github-builds' \
56+
--substitutions="_ARTIFACT_ID='cdap-e2e-tests',_SECURE_PUBLISH_BUCKET_NAME=${{ steps.gcp_secrets.outputs.secure_publish_bucket }}"
5857
59-
- name: Set up GPG conf
60-
run: |
61-
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
62-
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
63-
64-
- name: Build and Deploy
65-
working-directory: e2e
66-
run: mvn -B -V -DskipTests clean deploy -P release -Dgpg.passphrase=$CDAP_GPG_PASSPHRASE -Dmaven.wagon.http.retryHandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=30
67-
env:
68-
CDAP_OSSRH_USERNAME: ${{ steps.secrets.outputs.CDAP_OSSRH_USERNAME }}
69-
CDAP_OSSRH_PASSWORD: ${{ steps.secrets.outputs.CDAP_OSSRH_PASSWORD }}
70-
CDAP_GPG_PASSPHRASE: ${{ steps.secrets.outputs.CDAP_GPG_PASSPHRASE }}
71-
MAVEN_OPTS: '-Xmx3200m'

cloudbuild.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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+
steps:
13+
- name: 'maven:3.8-jdk-8'
14+
id: maven-package
15+
entrypoint: 'mvn'
16+
args:
17+
- -B
18+
- -U
19+
- clean
20+
- package
21+
- -DskipTests
22+
23+
- name: 'anchore/syft:v1.5.0'
24+
id: generate-sbom
25+
args:
26+
- 'packages'
27+
- '-o'
28+
- 'spdx-json=/workspace/attestations/project-sbom.spdx.json'
29+
- '.'
30+
waitFor: ['maven-package']
31+
32+
- name: 'bash'
33+
id: stage-artifacts
34+
entrypoint: 'bash'
35+
args:
36+
- '-c'
37+
- |
38+
set -e
39+
mkdir -p /workspace/staging
40+
# Ensure the attestations dir exists for the cp command
41+
mkdir -p /workspace/attestations
42+
43+
# Copy Maven artifacts from the 'target' directory
44+
echo "Copying Maven artifacts..."
45+
find target -name "*.jar" -exec cp {} /workspace/staging/ \;
46+
find target -name "*.pom" -exec cp {} /workspace/staging/ \;
47+
# Add other artifact types if necessary
48+
49+
# Copy SBOM
50+
echo "Copying SBOM..."
51+
if [ -f /workspace/attestations/project-sbom.spdx.json ]; then
52+
cp /workspace/attestations/project-sbom.spdx.json /workspace/staging/
53+
else
54+
echo "ERROR: SBOM file not found!"
55+
exit 1
56+
fi
57+
58+
# List staged files for debugging
59+
echo "Staged files:"
60+
ls -l /workspace/staging
61+
waitFor: ['generate-sbom']
62+
63+
- name: 'bash'
64+
id: create-manifest
65+
entrypoint: 'bash'
66+
args:
67+
- '-c'
68+
- |
69+
set -e
70+
echo "Creating manifest.json..."
71+
cd /workspace/staging
72+
printf '{\n "artifacts": [\n' > manifest.json
73+
find . -maxdepth 1 -type f ! -name "manifest.json" | sed 's|./||' | sed 's/.*/ "&",/' >> manifest.json
74+
# Remove trailing comma from the last line
75+
sed -i '$ s/,$//' manifest.json
76+
printf '\n ]\n}\n' >> manifest.json
77+
78+
echo "Generated manifest.json:"
79+
cat manifest.json
80+
cd /workspace
81+
waitFor: ['stage-artifacts']
82+
83+
- name: 'gcr.io/cloud-builders/gsutil'
84+
id: upload-to-staging
85+
args:
86+
- '-m'
87+
- 'cp'
88+
- '-r'
89+
- '/workspace/staging/*'
90+
- 'gs://${_SECURE_PUBLISH_BUCKET_NAME}/${_ARTIFACT_ID}/${BUILD_ID}/'
91+
waitFor: ['create-manifest']
92+
93+
options:
94+
requestedVerifyOption: VERIFIED
95+
machineType: 'E2_HIGHCPU_32'

0 commit comments

Comments
 (0)