Skip to content

Commit

Permalink
Merge pull request #670 from bounswe/chore/devops/migrate-do
Browse files Browse the repository at this point in the history
  • Loading branch information
mmtftr authored Dec 11, 2024
2 parents 93a8375 + f2747f2 commit 786bd78
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/prod_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,37 @@ jobs:

# Build a Docker image of the application and tag the image with the $GITHUB_SHA.
- name: Build backend image
run: docker build -t registry.digitalocean.com/programming-languages/backend:$(echo $GITHUB_SHA | head -c7) ./backend
run: docker build -t registry.digitalocean.com/programming-languages-2/backend:$(echo $GITHUB_SHA | head -c7) ./backend

- name: Build web image
run: docker build -t registry.digitalocean.com/programming-languages/web:$(echo $GITHUB_SHA | head -c7) ./frontend
run: docker build -t registry.digitalocean.com/programming-languages-2/web:$(echo $GITHUB_SHA | head -c7) ./frontend

- name: Log in to DigitalOcean Container Registry with short-lived credentials
run: doctl registry login --expiry-seconds 1200

# Push the Docker image to registry

- name: Push backend image
run: docker push registry.digitalocean.com/programming-languages/backend:$(echo $GITHUB_SHA | head -c7)
run: docker push registry.digitalocean.com/programming-languages-2/backend:$(echo $GITHUB_SHA | head -c7)

- name: Push web image
run: docker push registry.digitalocean.com/programming-languages/web:$(echo $GITHUB_SHA | head -c7)
run: docker push registry.digitalocean.com/programming-languages-2/web:$(echo $GITHUB_SHA | head -c7)

# tag as latest

- name: Tag backend image
run: docker tag registry.digitalocean.com/programming-languages/backend:$(echo $GITHUB_SHA | head -c7) registry.digitalocean.com/programming-languages/backend:latest
run: docker tag registry.digitalocean.com/programming-languages-2/backend:$(echo $GITHUB_SHA | head -c7) registry.digitalocean.com/programming-languages-2/backend:latest

- name: Tag web image
run: docker tag registry.digitalocean.com/programming-languages/web:$(echo $GITHUB_SHA | head -c7) registry.digitalocean.com/programming-languages/web:latest
run: docker tag registry.digitalocean.com/programming-languages-2/web:$(echo $GITHUB_SHA | head -c7) registry.digitalocean.com/programming-languages-2/web:latest

# Push the Docker image to registry

- name: Push backend image
run: docker push registry.digitalocean.com/programming-languages/backend:latest
run: docker push registry.digitalocean.com/programming-languages-2/backend:latest

- name: Push web image
run: docker push registry.digitalocean.com/programming-languages/web:latest
run: docker push registry.digitalocean.com/programming-languages-2/web:latest

- name: Create deployment again to ensure both images are up to date
run: doctl apps create-deployment 58cc1048-2af2-42f8-a71f-5d1085113742
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,24 @@ docker compose build

```bash
# for prod
docker tag bounswe2024group1-451-web:latest registry.digitalocean.com/programming-languages/web:latest
docker tag bounswe2024group1-451-backend:latest registry.digitalocean.com/programming-languages/backend:latest
docker tag bounswe2024group1-451-web:latest registry.digitalocean.com/programming-languages-2/web:latest
docker tag bounswe2024group1-451-backend:latest registry.digitalocean.com/programming-languages-2/backend:latest

# for staging
docker tag bounswe2024group1-451-web:latest registry.digitalocean.com/programming-languages/web:staging
docker tag bounswe2024group1-451-backend:latest registry.digitalocean.com/programming-languages/backend:staging
docker tag bounswe2024group1-451-web:latest registry.digitalocean.com/programming-languages-2/web:staging
docker tag bounswe2024group1-451-backend:latest registry.digitalocean.com/programming-languages-2/backend:staging
```

3. Push images to the registry.

```bash
# for prod
docker push registry.digitalocean.com/programming-languages/web:latest
docker push registry.digitalocean.com/programming-languages/backend:latest
docker push registry.digitalocean.com/programming-languages-2/web:latest
docker push registry.digitalocean.com/programming-languages-2/backend:latest

# for staging
docker push registry.digitalocean.com/programming-languages/web:staging
docker push registry.digitalocean.com/programming-languages/backend:staging
docker push registry.digitalocean.com/programming-languages-2/web:staging
docker push registry.digitalocean.com/programming-languages-2/backend:staging
```

This will trigger a deployment on the DigitalOcean backend.
Expand Down

0 comments on commit 786bd78

Please sign in to comment.