1- name : Gradle Build & Deploy - POC
1+ name : Gradle Build & Deploy - Develop
22on :
33 push :
44 branches :
55 # - 'develop'
6- - ' 2486-create-new-pipeline-for-updated-build-deployment'
7-
6+ - ' feature-2486/create-new-pipeline-for-updated-env'
7+ env :
8+ HUSKY : 0
9+ PROJECT_NUMBER : ${{ secrets.PROJECT_NUM }}
10+ PROJECT_ID : ${{ secrets.PROJECT_ID }}
11+ PROJECT_NAME : ${{ secrets.PROJECT_NAME }}
12+ RUN_REGION : us-central1
13+ SERVICE_NAME : checkins-develop
14+ TARGET_URL : https://checkins-develop.objectcomputing.com
815jobs :
9- build :
16+ test :
17+ runs-on : ubuntu-latest
18+ steps :
19+ - uses : actions/checkout@v4
20+ with :
21+ fetch-depth : 0
22+ - name : Set up Node Stable
23+ uses : actions/setup-node@v4
24+ with :
25+ node-version : ' 22'
26+ - name : Set up Temurin 21
27+ uses : actions/setup-java@v4
28+ with :
29+ distribution : ' temurin'
30+ java-version : 21
31+ - name : Cache Gradle packages
32+ uses : actions/cache@v4
33+ with :
34+ path : ~/.gradle/caches
35+ key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
36+ restore-keys : ${{ runner.os }}-gradle
37+ - name : Setup Gradle
38+ uses : gradle/actions/setup-gradle@v4
39+ - name : Run tests with Gradle
40+ run : ./gradlew check
41+ deploy :
1042 permissions :
11- id-token : ' write'
43+ contents : ' read'
44+ id-token : ' write'
1245 runs-on : ubuntu-latest
1346 environment :
1447 name : DEV-POC
15- # url: ${{ env.CLOUD_RUN_ADDRESS }}/
16- env :
17- PROJECT_NUMBER : ${{ secrets.PROJECT_NUM }}
18- PROJECT_ID : ${{ secrets.PROJECT_ID }}
19- PROJECT_NAME : ${{ secrets.PROJECT_NAME }}
20- RUN_REGION : us-central1
21- SERVICE_NAME : checkins-develop
48+ url : ${{ env.TARGET_URL }}/
2249 steps :
2350 - uses : actions/checkout@v4
2451 with :
2552 fetch-depth : 0 # Shallow clones should be disabled for a better relevancy of analysis
26- - id : ' auth_with_gcp'
27- uses : ' google-github-actions/auth@v2'
28- with :
29- project_id : ' ${{secrets.PROJECT_NUM}}'
30- workload_identity_provider : ' ${{secrets.WORKLOAD_IDENTITY_PROVIDER}}'
31- service_account : ' ${{secrets.AUTOMATION_SERVICE_ACCOUNT}}'
32- - id : ' secrets'
33- uses : ' google-github-actions/get-secretmanager-secrets@v2'
34- with :
35- secrets : |-
36- cloud_run_address:${{secrets.PROJECT_NUM}}/CLOUD_RUN_ADDRESS
37- cloud_db_connection_name:${{secrets.PROJECT_NUM}}/CLOUD_DB_CONNECTION_NAME
38- connector_id:${{secrets.PROJECT_NUM}}/CONNECTOR_ID
3953 - name : Set up Node LTS
4054 uses : actions/setup-node@v4
4155 with :
42- node-version : ' 20 '
43- - name : Set up JDK 21
56+ node-version : ' 22 '
57+ - name : Set up Temurin 21
4458 uses : actions/setup-java@v4
4559 with :
4660 distribution : ' temurin' # See 'Supported distributions' for available options
4761 java-version : 21
48- - name : Cache SonarQube packages
49- uses : actions/cache@v4
50- with :
51- path : ~/.sonar/cache
52- key : ${{ runner.os }}-sonar
53- restore-keys : ${{ runner.os }}-sonar
5462 - name : Cache Gradle packages
5563 uses : actions/cache@v4
5664 with :
5765 path : ~/.gradle/caches
5866 key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
5967 restore-keys : ${{ runner.os }}-gradle
60- - name : Validate Gradle wrapper
61- uses : gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
62- - name : Build with Gradle
63- uses : gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021
68+ - name : Setup Gradle
69+ uses : gradle/actions/setup-gradle@v4
70+ - id : ' auth '
71+ uses : ' google-github-actions/auth@v2 '
6472 with :
65- arguments : assemble
66- env :
67- VITE_APP_API_URL : ${{steps.secrets.outputs.cloud_run_address}}
68- - name : Gradle runs tests
69- uses : gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021
73+ project_id : ${{ secrets.PROJECT_ID }}
74+ workload_identity_provider : ' projects/832140020593/locations/global/workloadIdentityPools/github/providers/my-repo'
75+ - id : ' secrets'
76+ uses : ' google-github-actions/get-secretmanager-secrets@v2'
7077 with :
71- arguments : check
72- # - name: Do SonarQube checks
73- # uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021
74- # with:
75- # arguments: sonarqube --info
76- # env:
77- # GITHUB_TOKEN: ${{ secrets.GIT_HUB_TOKEN }}
78- # SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
79- # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
80- - name : Setup python
81- run : |
82- sudo apt-get install python2.7
83- - name : Export gcloud related env variable
84- run : export CLOUDSDK_PYTHON="/usr/bin/python2"
85- # Setup gcloud CLI
86- - uses : google-github-actions/setup-gcloud@v2
78+ secrets : |-
79+ cloud_run_address:${{secrets.PROJECT_NUM}}/CLOUD_RUN_ADDRESS
80+ cloud_db_connection_name:${{secrets.PROJECT_NUM}}/CLOUD_DB_CONNECTION_NAME
81+ connector_id:${{secrets.PROJECT_NUM}}/CONNECTOR_ID
82+ - name : ' Set up Cloud SDK'
83+ uses : google-github-actions/setup-gcloud@v2
8784 with :
88- version : " 477.0.0"
89- # service_account_key: ${{ secrets.RUN_SA_KEY }}
90- # project_id: ${{ secrets.RUN_PROJECT }}
91- - name : Auth Configure Docker
85+ version : ' >= 363.0.0'
86+ - name : ' Auth Configure Docker'
9287 run : |-
9388 gcloud --quiet auth configure-docker
9489 - name : Build the Docker image
9590 run : |-
91+ ./gradlew assemble
9692 cd server
9793 docker build --tag "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" .
94+ env :
95+ VITE_APP_API_URL : ${{ env.TARGET_URL }}
9896 - name : Push the Docker image to Google Container Registry
99- run : |-
100- cd server
101- docker push "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA"
97+ run : docker push "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA"
10298 - name : Deploy image to Cloud Run
10399 run : |-
104100 gcloud run deploy "$SERVICE_NAME" \
101+ --quiet \
105102 --project "$PROJECT_ID" \
106103 --region "$RUN_REGION" \
107104 --image "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" \
@@ -119,6 +116,10 @@ jobs:
119116 --set-secrets "SERVICE_ACCOUNT_CREDENTIALS=SERVICE_ACCOUNT_CREDENTIALS:latest" \
120117 --set-secrets "WEB_ADDRESS=CLOUD_RUN_ADDRESS:latest" \
121118 --set-secrets "MICRONAUT_ENVIRONMENTS=MICRONAUT_ENVIRONMENTS:latest" \
119+ --set-env-vars "SLACK_WEBHOOK_URL=${{ secrets.SLACK_WEBHOOK_URL }}" \
120+ --set-env-vars "SLACK_BOT_TOKEN=${{ secrets.SLACK_BOT_TOKEN }}" \
121+ --set-env-vars "SLACK_SIGNING_SECRET=${{ secrets.SLACK_PULSE_SIGNING_SECRET }}" \
122+ --set-env-vars "SLACK_KUDOS_CHANNEL_ID=${{ secrets.SLACK_KUDOS_CHANNEL_ID }}" \
122123 --platform "managed" \
123124 --max-instances 2 \
124125 --allow-unauthenticated
0 commit comments