Skip to content

Commit

Permalink
Split out the actions
Browse files Browse the repository at this point in the history
  • Loading branch information
timyates committed Sep 18, 2024
1 parent e22f66e commit f7f1524
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 103 deletions.
60 changes: 0 additions & 60 deletions .github/workflows/gradle-build-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
push:
branches:
- 'develop'

env:
PROJECT_ID: ${{ secrets.RUN_PROJECT }}
RUN_REGION: us-central1
Expand Down Expand Up @@ -51,62 +50,3 @@ jobs:
uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021
with:
arguments: check
# - name: Do SonarQube checks
# uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021
# with:
# arguments: sonarqube --info
# env:
# GITHUB_TOKEN: ${{ secrets.GIT_HUB_TOKEN }}
# SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Setup python
run: |
sudo apt-get install python2.7
- name: Export gcloud related env variable
run: export CLOUDSDK_PYTHON="/usr/bin/python2"
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@v0
with:
version: "290.0.1"
service_account_key: ${{ secrets.RUN_SA_KEY }}
project_id: ${{ secrets.RUN_PROJECT }}
- name: Auth Configure Docker
run: |-
gcloud --quiet auth configure-docker
- name: Build the Docker image
run: |-
cd server
docker build --tag "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" .
- name: Push the Docker image to Google Container Registry
run: |-
cd server
docker push "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA"
- name: Deploy image to Cloud Run
run: |-
gcloud run deploy "$SERVICE_NAME" \
--quiet \
--region "$RUN_REGION" \
--image "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" \
--memory 1Gi \
--add-cloudsql-instances ${{ secrets.DB_CONNECTION_NAME }} \
--set-env-vars "CLOUD_DB_CONNECTION_NAME=${{ secrets.DB_CONNECTION_NAME }}" \
--set-env-vars "DB_NAME=${{ secrets.DB_NAME }}" \
--set-env-vars "DATASOURCES_DEFAULT_PASSWORD=${{ secrets.DB_PASSWORD }}" \
--set-env-vars "DATASOURCES_DEFAULT_USERNAME=${{ secrets.DB_USERNAME }}" \
--set-env-vars "AES_KEY=${{ secrets.AES_KEY }}" \
--set-env-vars "OAUTH_CLIENT_ID=${{ secrets.OAUTH_CLIENT_ID }}" \
--set-env-vars "OAUTH_CLIENT_SECRET=${{ secrets.OAUTH_CLIENT_SECRET }}" \
--set-env-vars "OAUTH_CALLBACK_URI"=${{ secrets.OAUTH_CALLBACK_URI }} \
--set-env-vars "DIRECTORY_ID=${{ secrets.DIRECTORY_ID }}" \
--set-env-vars "SERVICE_ACCOUNT_CREDENTIALS=${{ secrets.SERVICE_ACCOUNT_CREDENTIALS }}" \
--set-env-vars "GSUITE_SUPER_ADMIN=${{ secrets.GSUITE_SUPER_ADMIN }}" \
--set-env-vars "MJ_APIKEY_PUBLIC=${{ secrets.MJ_APIKEY_PUBLIC }}" \
--set-env-vars "MJ_APIKEY_PRIVATE=${{ secrets.MJ_APIKEY_PRIVATE }}" \
--set-env-vars "GIT_HUB_TOKEN=${{ secrets.GIT_HUB_TOKEN }}" \
--set-env-vars "WEB_ADDRESS=https://checkins-develop-tuvcfzotpq-uc.a.run.app" \
--set-env-vars "[email protected]" \
--set-env-vars "FROM_NAME=Check-Ins - DEVELOP" \
--set-env-vars "^@^MICRONAUT_ENVIRONMENTS=dev,cloud,google,gcp" \
--platform "managed" \
--max-instances 2 \
--allow-unauthenticated
8 changes: 0 additions & 8 deletions .github/workflows/gradle-build-feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,3 @@ jobs:
uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021
with:
arguments: check
# - name: Do SonarQube checks
# uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021
# with:
# arguments: sonarqube --info
# env:
# GITHUB_TOKEN: ${{ secrets.GIT_HUB_TOKEN }}
# SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
119 changes: 119 additions & 0 deletions .github/workflows/gradle-deploy-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Gradle Build & Deploy - Develop
on:
push:
branches:
- 'develop'
- 'feature-2532/graal'
env:
PROJECT_ID: ${{ secrets.RUN_PROJECT }}
RUN_REGION: us-central1
SERVICE_NAME: checkins-develop
URL: https://checkins-develop-tuvcfzotpq-uc.a.run.app
jobs:
deploy:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
environment:
name: Development
url: ${{ env.URL }}
steps:
- name: 'πŸ›’ Checkout'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'πŸ“ Set up Node LTS'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: 'β˜•οΈ Set up JDK 21'
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
- name: 'πŸͺ£ Cache Gradle packages'
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: '🐘 Setup Gradle'
uses: gradle/actions/setup-gradle@v4
- name: '🐍 Setup python'
run: |
sudo apt-get install python2.7
- name: '🐍 Export gcloud related env variable'
run: export CLOUDSDK_PYTHON="/usr/bin/python2"
- name: '☁️ Setup gcloud'
uses: google-github-actions/setup-gcloud@v0
with:
version: "290.0.1"
service_account_key: ${{ secrets.RUN_SA_KEY }}
project_id: ${{ secrets.RUN_PROJECT }}
- name: '🐳 Auth Configure Docker'
run: |-
gcloud --quiet auth configure-docker
- name: '🐳 Build the Docker image'
run: |-
cd server
docker build --tag "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" .
- name: '🐳 Push the Docker image to Google Container Registry'
run: |-
cd server
docker push "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA"
- name: 'πŸƒ Deploy image to Cloud Run'
run: |-
gcloud run deploy "$SERVICE_NAME" \
--quiet \
--region "$RUN_REGION" \
--image "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" \
--memory 1Gi \
--add-cloudsql-instances ${{ secrets.DB_CONNECTION_NAME }} \
--set-env-vars "CLOUD_DB_CONNECTION_NAME=${{ secrets.DB_CONNECTION_NAME }}" \
--set-env-vars "DB_NAME=${{ secrets.DB_NAME }}" \
--set-env-vars "DATASOURCES_DEFAULT_PASSWORD=${{ secrets.DB_PASSWORD }}" \
--set-env-vars "DATASOURCES_DEFAULT_USERNAME=${{ secrets.DB_USERNAME }}" \
--set-env-vars "AES_KEY=${{ secrets.AES_KEY }}" \
--set-env-vars "OAUTH_CLIENT_ID=${{ secrets.OAUTH_CLIENT_ID }}" \
--set-env-vars "OAUTH_CLIENT_SECRET=${{ secrets.OAUTH_CLIENT_SECRET }}" \
--set-env-vars "OAUTH_CALLBACK_URI"=${{ secrets.OAUTH_CALLBACK_URI }} \
--set-env-vars "DIRECTORY_ID=${{ secrets.DIRECTORY_ID }}" \
--set-env-vars "SERVICE_ACCOUNT_CREDENTIALS=${{ secrets.SERVICE_ACCOUNT_CREDENTIALS }}" \
--set-env-vars "GSUITE_SUPER_ADMIN=${{ secrets.GSUITE_SUPER_ADMIN }}" \
--set-env-vars "MJ_APIKEY_PUBLIC=${{ secrets.MJ_APIKEY_PUBLIC }}" \
--set-env-vars "MJ_APIKEY_PRIVATE=${{ secrets.MJ_APIKEY_PRIVATE }}" \
--set-env-vars "GIT_HUB_TOKEN=${{ secrets.GIT_HUB_TOKEN }}" \
--set-env-vars "WEB_ADDRESS=${{ env.URL }}" \
--set-env-vars "[email protected]" \
--set-env-vars "FROM_NAME=Check-Ins - DEVELOP" \
--set-env-vars "^@^MICRONAUT_ENVIRONMENTS=dev,cloud,google,gcp" \
--platform "managed" \
--max-instances 2 \
--allow-unauthenticated
test:
runs-on: ubuntu-latest
steps:
- name: 'πŸ›’ Checkout'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'πŸ“ Set up Node LTS'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: 'β˜•οΈ Set up JDK 21'
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
- name: 'πŸͺ£ Cache Gradle packages'
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: '🐘 Setup Gradle'
uses: gradle/actions/setup-gradle@v4
- name: '🐘 Run tests with Gradle'
run: ./gradlew check
69 changes: 34 additions & 35 deletions .github/workflows/gradle-deploy-native-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
PROJECT_ID: ${{ secrets.RUN_PROJECT }}
RUN_REGION: us-central1
SERVICE_NAME: checkins-develop-native
URL: https://checkins-develop-native-832140020593.us-central1.run.app
jobs:
deploy:
permissions:
Expand All @@ -16,54 +17,51 @@ jobs:
runs-on: ubuntu-latest
environment:
name: Development - Native
url: https://checkins-develop-native-832140020593.us-central1.run.app
url: ${{ env.URL }}
steps:
- uses: actions/checkout@v4
- name: 'πŸ›’ Checkout'
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up Node LTS
fetch-depth: 0
- name: 'πŸ“ Set up Node LTS'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Set up GraalVM 21
- name: 'β˜•οΈ Set up GraalVM 21'
uses: graalvm/[email protected]
with:
distribution: 'graalvm'
java-version: '21'
- name: Cache Gradle packages
- name: 'πŸͺ£ Cache Gradle packages'
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Setup Gradle
- name: '🐘 Setup Gradle'
uses: gradle/actions/setup-gradle@v4
# - name: Setup python
# run: |
# sudo apt-get install python2.7
# - name: Export gcloud related env variable
# run: export CLOUDSDK_PYTHON="/usr/bin/python2"
- id: 'auth'
uses: 'google-github-actions/auth@v2'
- name: '🐍 Setup python'
run: |
sudo apt-get install python2.7
- name: '🐍 Export gcloud related env variable'
run: export CLOUDSDK_PYTHON="/usr/bin/python2"
- name: '☁️ Setup gcloud'
uses: google-github-actions/setup-gcloud@v0
with:
project_id: 'oci-intern-2019'
workload_identity_provider: 'projects/832140020593/locations/global/workloadIdentityPools/github/providers/my-repo'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
with:
version: '>= 363.0.0'
- name: 'Auth Configure Docker'
run: |-
gcloud --quiet auth configure-docker
- name: Build a native docker image
version: "290.0.1"
service_account_key: ${{ secrets.RUN_SA_KEY }}
project_id: ${{ secrets.RUN_PROJECT }}
- name: '🐳 Auth Configure Docker'
run: gcloud --quiet auth configure-docker
- name: '🐳 Build the Native Docker image'
run: ./gradlew dockerBuildNative
env:
VITE_APP_API_URL: https://checkins-develop-native-832140020593.us-central1.run.app
- name: Push the Docker image to Google Container Registry
VITE_APP_API_URL: ${{ env.URL }}
- name: '🐳 Push the Docker image to Google Container Registry'
run: |-
cd server
docker push "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA"
- name: Deploy image to Cloud Run
- name: 'πŸƒ Deploy image to Cloud Run'
run: |-
gcloud run deploy "$SERVICE_NAME" \
--quiet \
Expand All @@ -85,7 +83,7 @@ jobs:
--set-env-vars "MJ_APIKEY_PUBLIC=${{ secrets.MJ_APIKEY_PUBLIC }}" \
--set-env-vars "MJ_APIKEY_PRIVATE=${{ secrets.MJ_APIKEY_PRIVATE }}" \
--set-env-vars "GIT_HUB_TOKEN=${{ secrets.GIT_HUB_TOKEN }}" \
--set-env-vars "WEB_ADDRESS=https://checkins-develop-native-832140020593.us-central1.run.app" \
--set-env-vars "WEB_ADDRESS=${{ env.URL }}" \
--set-env-vars "[email protected]" \
--set-env-vars "FROM_NAME=Check-Ins - DEVELOP" \
--set-env-vars "^@^MICRONAUT_ENVIRONMENTS=dev,cloud,google,gcp" \
Expand All @@ -95,25 +93,26 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'πŸ›’ Checkout'
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up Node LTS
fetch-depth: 0
- name: 'πŸ“ Set up Node LTS'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Set up GraalVM 21
- name: 'β˜•οΈ Set up GraalVM 21'
uses: graalvm/[email protected]
with:
distribution: 'graalvm'
java-version: '21'
- name: Cache Gradle packages
- name: 'πŸͺ£ Cache Gradle packages'
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Setup Gradle
- name: '🐘 Setup Gradle'
uses: gradle/actions/setup-gradle@v4
- name: Run tests with Gradle
- name: '🐘 Run tests with Gradle'
run: ./gradlew nativeTest

0 comments on commit f7f1524

Please sign in to comment.