Merge pull request #79 from KjellBerlin/Modify-readme #77
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Staging | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: '${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}' | |
- name: Configure gcloud | |
run: gcloud config set project ${{ secrets.GCP_PROJECT_ID }} | |
- name: Authenticate Docker to Google Artifact Registry | |
run: gcloud auth configure-docker europe-west3-docker.pkg.dev | |
- name: Build with Gradle | |
run: ./gradlew build | |
- name: Build Docker image | |
env: | |
GITHUB_SHA: ${{ github.sha }} | |
run: | | |
docker build -t europe-west3-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.ARTIFACT_REGISTRY_REPO }}/carbonara-core:${GITHUB_SHA} . | |
docker push europe-west3-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.ARTIFACT_REGISTRY_REPO }}/carbonara-core:${GITHUB_SHA} | |
- name: Deploy to Cloud Run | |
env: | |
GITHUB_SHA: ${{ github.sha }} | |
run: | | |
gcloud run deploy ${{ secrets.CLOUD_RUN_SERVICE }} \ | |
--image europe-west3-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.ARTIFACT_REGISTRY_REPO }}/carbonara-core:${GITHUB_SHA} \ | |
--platform managed \ | |
--region europe-west1 \ | |
--allow-unauthenticated \ | |
--set-env-vars SPRING_PROFILES_ACTIVE=staging | |
- name: Clean up | |
env: | |
GITHUB_SHA: ${{ github.sha }} | |
run: docker rmi europe-west3-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.ARTIFACT_REGISTRY_REPO }}/carbonara-core:${GITHUB_SHA} |