Skip to content

Commit

Permalink
Merge pull request #387 from carbon-bond/add_production_workflow
Browse files Browse the repository at this point in the history
新增 production 所需 workflow
  • Loading branch information
MROS authored May 20, 2022
2 parents 71ab834 + 2dbd28c commit fcf284e
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 14 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/api-service-build-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: api-service-build-production

on:
release:
types: [ published ]

defaults:
run:
shell: bash
working-directory: ./api-service

jobs:
release:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v1
with:
working-directory: ./api-service
- name: 編譯
run: sh ./build.sh
- name: 登入 DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 建構並推送 docker 映像檔
uses: docker/build-push-action@v2
with:
context: ./api-service
push: true
tags: carbonbond/api-service:stable
file: ./api-service/deploy/Dockerfile
- name: 佈屬到正式環境
if: ${{ success() }}
uses: distributhor/workflow-webhook@v2
env:
webhook_url: ${{ secrets.PRODUCTION_WEBHOOK_URL }}/hooks/redeploy-api-service
webhook_secret: ${{ secrets.PRODUCTION_WEBHOOK_SECRET }}
verify_ssl: false
verbose: true
10 changes: 4 additions & 6 deletions .github/workflows/api-service-build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: api-service-build
name: api-service-build-dev

on:
release:
types: [ published ]
push:
branches: [ release, master ]
branches: [ master ]

defaults:
run:
Expand Down Expand Up @@ -40,7 +38,7 @@ jobs:
if: ${{ success() }}
uses: distributhor/workflow-webhook@v2
env:
webhook_url: ${{ secrets.WEBHOOK_URL }}/hooks/redeploy-api-service
webhook_secret: ${{ secrets.WEBHOOK_SECRET }}
webhook_url: ${{ secrets.DEV_WEBHOOK_URL }}/hooks/redeploy-api-service
webhook_secret: ${{ secrets.DEV_WEBHOOK_SECRET }}
verify_ssl: false
verbose: true
44 changes: 44 additions & 0 deletions .github/workflows/frontend-build-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: frontend-build-production

on:
release:
types: [ published ]

defaults:
run:
shell: bash
working-directory: ./frontend

jobs:
release:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '14.x'
- uses: c-hive/gha-yarn-cache@v2
with:
directory: ./frontend
- run: yarn install
- run: yarn build
- name: 登入 DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 建構並推送 docker 映像檔
uses: docker/build-push-action@v2
with:
context: ./frontend
push: true
tags: carbonbond/frontend:stable
file: ./frontend/deploy/Dockerfile
- name: 佈屬到正式環境
if: ${{ success() }}
uses: distributhor/workflow-webhook@v2
env:
webhook_url: ${{ secrets.PRODUCTION_WEBHOOK_URL }}/hooks/redeploy-frontend
webhook_secret: ${{ secrets.PRODUCTION_WEBHOOK_SECRET }}
verify_ssl: false
verbose: true
10 changes: 4 additions & 6 deletions .github/workflows/frontend-build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: frontend-build
name: frontend-build-dev

on:
release:
types: [ published ]
push:
branches: [ release, master ]
branches: [ master ]

defaults:
run:
Expand Down Expand Up @@ -40,7 +38,7 @@ jobs:
if: ${{ success() }}
uses: distributhor/workflow-webhook@v2
env:
webhook_url: ${{ secrets.WEBHOOK_URL }}/hooks/redeploy-frontend
webhook_secret: ${{ secrets.WEBHOOK_SECRET }}
webhook_url: ${{ secrets.DEV_WEBHOOK_URL }}/hooks/redeploy-frontend
webhook_secret: ${{ secrets.DEV_WEBHOOK_SECRET }}
verify_ssl: false
verbose: true
4 changes: 2 additions & 2 deletions deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
networks:
- carbonbond-net
frontend:
image: carbonbond/frontend:latest
image: "carbonbond/frontend:${TAG:-latest}"
# 欲自行建置 docker image ,以下三行取代上一行
# build:
# context: ../frontend
Expand All @@ -29,7 +29,7 @@ services:
networks:
- carbonbond-net
api-service:
image: carbonbond/api-service:latest
image: "carbonbond/api-service:${TAG:-latest}"
# 欲自行建置 docker image ,以下三行取代上一行
# build:
# context: ../api-service
Expand Down

0 comments on commit fcf284e

Please sign in to comment.