Skip to content

Commit

Permalink
Refactor build and deploy workflow, add Heroku deployment
Browse files Browse the repository at this point in the history
- Refactored the "setup-build-publish-deploy" job in the build-and-deploy-to-gcr.yaml file to "setup-build-publish"
- Updated the name of the job to "Build & publish image to GCR"
- Removed unnecessary steps related to Kubernetes deployment
- Added a new workflow file deploy-to-heroku.yml for deploying to Heroku
- Created a matrix strategy for deploying to multiple Heroku apps
- Added steps for checking out code and deploying to Heroku in the deploy job of deploy-to-heroku.yml
- Updated .gitignore file by adding ".DS_Store"
- Deleted unneeded files: unistudents-cb.yml, unistudents-prod1.yml, unistudents-prod2.yml, unistudents-prod3.yml, deployment.yml, kustomization.yaml
  • Loading branch information
unistudents-bot committed Feb 12, 2024
1 parent 03fae5b commit 4e1c39b
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 198 deletions.
29 changes: 3 additions & 26 deletions .github/workflows/build-and-deploy-to-gcr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ env:
IMAGE: unistudents-api

jobs:
setup-build-publish-deploy:
name: Build & deploy container
setup-build-publish:
name: Build & publish image to GCR
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -44,27 +44,4 @@ jobs:
run: gcloud builds submit --suppress-logs --pack image=europe-west1-docker.pkg.dev/unistudents-faa49/unistudents-api/unistudents-api

- name: Tag the latest commit
run: gcloud artifacts docker tags add $(gcloud artifacts docker images list europe-west1-docker.pkg.dev/unistudents-faa49/unistudents-api/unistudents-api --filter="package=europe-west1-docker.pkg.dev/unistudents-faa49/unistudents-api/unistudents-api" --sort-by="~UPDATE_TIME" --limit=1 --format="value(format("{0}@{1}",package,version))") $(gcloud artifacts docker images list europe-west1-docker.pkg.dev/unistudents-faa49/unistudents-api/unistudents-api/ --filter="package=europe-west1-docker.pkg.dev/unistudents-faa49/unistudents-api/unistudents-api" --sort-by="~UPDATE_TIME" --limit=1 --format="value(format("{0}",package))"):$GITHUB_SHA

# - name: Preparing the k8s toolset (Step 1/2)
# run: |-
# curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
# chmod u+x ./kustomize

# - name: Preparing the k8s toolset (Step 2/2)
# uses: google-github-actions/get-gke-credentials@v0
# with:
# cluster_name: ${{ env.GKE_CLUSTER }}
# location: ${{ env.GKE_ZONE }}
# project_id: ${{ env.PROJECT_ID }}

# - name: Deploy to Serverless farm
# run: gcloud run deploy unistudents-api --region=europe-west1 --image="europe-west1-docker.pkg.dev/unistudents-faa49/unistudents-api/unistudents-api:$GITHUB_SHA"

# - name: Deploy to k8s cluster
# run: |-
# # replacing the image name in the k8s template
# ./kustomize edit set image LOCATION-docker.pkg.dev/PROJECT_ID/REPOSITORY/IMAGE:TAG=europe-west1-docker.pkg.dev/unistudents-faa49/unistudents-api/unistudents-api:$GITHUB_SHA
# ./kustomize build . | kubectl apply -f -
# kubectl rollout status deployment/$DEPLOYMENT_NAME
# kubectl get services -o wide
run: gcloud artifacts docker tags add $(gcloud artifacts docker images list europe-west1-docker.pkg.dev/unistudents-faa49/unistudents-api/unistudents-api --filter="package=europe-west1-docker.pkg.dev/unistudents-faa49/unistudents-api/unistudents-api" --sort-by="~UPDATE_TIME" --limit=1 --format="value(format("{0}@{1}",package,version))") $(gcloud artifacts docker images list europe-west1-docker.pkg.dev/unistudents-faa49/unistudents-api/unistudents-api/ --filter="package=europe-west1-docker.pkg.dev/unistudents-faa49/unistudents-api/unistudents-api" --sort-by="~UPDATE_TIME" --limit=1 --format="value(format("{0}",package))"):$GITHUB_SHA
22 changes: 22 additions & 0 deletions .github/workflows/deploy-to-heroku.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Deploy to Heroku

on:
push:
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
app_name: ['unistudents-prod-1', 'unistudents-prod-4', 'unistudents-prod-5', 'unistudents-prod-6']
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Deploy to Heroku
uses: akhileshns/[email protected] # This is the Heroku deployment action
with:
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
heroku_app_name: ${{ matrix.app_name }}
heroku_email: ${{ secrets.HEROKU_EMAIL }}
17 changes: 0 additions & 17 deletions .github/workflows/unistudents-cb.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/unistudents-prod1.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/unistudents-prod2.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/unistudents-prod3.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/unistudents-prod4.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ build/
### VS Code ###
.vscode/

logback-test.xml
logback-test.xml
.DS_Store
81 changes: 0 additions & 81 deletions deployment.yml

This file was deleted.

5 changes: 0 additions & 5 deletions kustomization.yaml

This file was deleted.

0 comments on commit 4e1c39b

Please sign in to comment.