Skip to content

Commit

Permalink
use reusable workflows in prod and stage
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmwang committed Sep 29, 2024
1 parent 2d97918 commit dba3fbd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 77 deletions.
46 changes: 8 additions & 38 deletions .github/workflows/cd-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,17 @@ jobs:
- name: Pass
run: echo "Passed check"

build-push-backend:
name: Build and Push Backend Image
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Image with Tag
run: |
docker build --platform=linux/amd64 --target backend-prod --tag "${{ secrets.DOCKER_USERNAME }}/bt-backend:prod" .
docker push "${{ secrets.DOCKER_USERNAME }}/bt-backend:prod"
build-push-frontend:
name: Build and Push Frontend Image
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Image with Tag
run: |
docker build --platform=linux/amd64 --target frontend-prod --tag "${{ secrets.DOCKER_USERNAME }}/bt-frontend:prod" .
docker push "${{ secrets.DOCKER_USERNAME }}/bt-frontend:prod"
build-push:
name: Build and Push Images
needs: [branch-check]
uses: ./.github/workflows/cd.yaml
with:
tag: prod
secrets: inherit

deploy:
name: Deploy with SSH
needs: [build-push-backend, build-push-frontend]
needs: [build-push]
runs-on: ubuntu-latest

steps:
Expand Down
47 changes: 8 additions & 39 deletions .github/workflows/cd-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,19 @@ concurrency: stage

on:
push:
branches: [master]
branches: [master, gql]

jobs:
build-push-backend:
name: Build and Push Backend Image
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Image with Tag
run: |
docker build --platform=linux/amd64 --target backend-prod --tag "${{ secrets.DOCKER_USERNAME }}/bt-backend:latest" .
docker push "${{ secrets.DOCKER_USERNAME }}/bt-backend:latest"
build-push-frontend:
name: Build and Push Frontend Image
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Image with Tag
run: |
docker build --platform=linux/amd64 --target frontend-prod --tag "${{ secrets.DOCKER_USERNAME }}/bt-frontend:latest" .
docker push "${{ secrets.DOCKER_USERNAME }}/bt-frontend:latest"
build-push:
name: Build and Push Images
uses: ./.github/workflows/cd.yaml
with:
tag: latest
secrets: inherit

deploy:
name: Deploy with SSH
needs: [build-push-backend, build-push-frontend]
needs: [build-push]
runs-on: ubuntu-latest
environment: staging

Expand Down

0 comments on commit dba3fbd

Please sign in to comment.