forked from hxt001/booking-system-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
seperate frontend and backend workflows
- Loading branch information
1 parent
79aa89c
commit e6ce572
Showing
4 changed files
with
143 additions
and
117 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: CI workflow for backend | ||
|
||
on: push | ||
# push: | ||
# paths: | ||
# - "backend/**" | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '11' | ||
distribution: 'adopt' | ||
cache: gradle | ||
|
||
- name: Test backend | ||
run: | | ||
cd backend | ||
./gradlew test | ||
build-and-push-backend: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.ref_name == 'main' }} | ||
needs: test | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '11' | ||
distribution: 'adopt' | ||
cache: gradle | ||
|
||
- name: Build bootJar | ||
run: | | ||
cd backend | ||
./gradlew bootJar | ||
- name: Build Image and Deploy | ||
uses: ./.github/workflows/build-deploy.yml | ||
with: | ||
folder: backend | ||
image_name: booking-backend | ||
deployment_name: booking-backend |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Reusable workflow to build and deploy | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
folder: | ||
required: true | ||
type: string | ||
image_name: | ||
required: true | ||
type: string | ||
deployment_name: | ||
required: true | ||
type: string | ||
|
||
env: | ||
PROJECT_ID: pivot-lab-2203 | ||
GKE_CLUSTER: booking-app-cluster | ||
GKE_ZONE: us-west1 | ||
DOCKER_REGISTRY: us-west1-docker.pkg.dev/pivot-lab-2203/docker-image-repo | ||
|
||
jobs: | ||
build-image-and-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- id: auth | ||
name: Authenticate to Google Cloud | ||
uses: google-github-actions/auth@v0 | ||
with: | ||
credentials_json: '${{ secrets.GOOGLE_SA_CREDENTIALS }}' | ||
token_format: access_token | ||
|
||
- uses: docker/setup-buildx-action@v1 | ||
|
||
- uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ env.DOCKER_REGISTRY }} | ||
username: oauth2accesstoken | ||
password: '${{ steps.auth.outputs.access_token }}' | ||
|
||
- name: Build and push image to artifact registry | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: ${{ inputs.folder }} | ||
file: ${{ inputs.folder }}/Dockerfile | ||
push: true | ||
tags: ${{ env.DOCKER_REGISTRY }}/${{ inputs.image_name }}:latest | ||
|
||
update-image: | ||
runs-on: ubuntu-latest | ||
needs: build-and-push | ||
steps: | ||
- id: auth | ||
name: Authenticate to Google Cloud | ||
uses: google-github-actions/auth@v0 | ||
with: | ||
credentials_json: '${{ secrets.GOOGLE_SA_CREDENTIALS }}' | ||
token_format: access_token | ||
|
||
- name: Set up Cloud SDK | ||
uses: google-github-actions/setup-gcloud@v0 | ||
with: | ||
project_id: ${{ env.PROJECT_ID }} | ||
install_components: kubectl | ||
|
||
- run: |- | ||
gcloud container clusters get-credentials "$GKE_CLUSTER" --zone "$GKE_ZONE" | ||
- name: Deploy | ||
run: |- | ||
kubectl rollout restart deployment ${{ inputs.deployment_name }} | ||
kubectl rollout status deployment ${{ inputs.deployment_name }} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: CI workflow for frontend | ||
|
||
on: push | ||
# push: | ||
# paths: | ||
# - "booking-system-ui/**" | ||
|
||
jobs: | ||
build-and-push-frontend: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.ref_name == 'main' }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Build Image and Deploy | ||
uses: ./.github/workflows/build-deploy.yml | ||
with: | ||
folder: backend | ||
image_name: booking-backend | ||
deployment_name: booking-backend |
This file was deleted.
Oops, something went wrong.