ci: add deployment workflows for different services
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
name: Deploy (reusable)
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
module:
|
||||
description: "Skaffold module: orion, worker, pusher, emailnotifierjob, memberreconciler, or migrations"
|
||||
required: true
|
||||
type: string
|
||||
environment:
|
||||
description: "Target environment: dev or prod"
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
environment: ${{ inputs.environment }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: go
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go/go.mod
|
||||
cache-dependency-path: go/go.sum
|
||||
|
||||
- name: Resolve environment settings
|
||||
id: env
|
||||
run: |
|
||||
if [ "${{ inputs.environment }}" = "prod" ]; then
|
||||
echo "project=flowy-prod-440017" >> "$GITHUB_OUTPUT"
|
||||
echo "cluster=${{ vars.PROD_GKE_CLUSTER_NAME }}" >> "$GITHUB_OUTPUT"
|
||||
echo "region=${{ vars.PROD_GKE_REGION }}" >> "$GITHUB_OUTPUT"
|
||||
elif [ "${{ inputs.environment }}" = "dev" ]; then
|
||||
echo "project=flowy-dev-440017" >> "$GITHUB_OUTPUT"
|
||||
echo "cluster=${{ vars.DEV_GKE_CLUSTER_NAME }}" >> "$GITHUB_OUTPUT"
|
||||
echo "region=${{ vars.DEV_GKE_REGION }}" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "Unknown environment: ${{ inputs.environment }}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Run tests
|
||||
run: go test ./...
|
||||
|
||||
- name: Authenticate to Google Cloud
|
||||
uses: google-github-actions/auth@v2
|
||||
with:
|
||||
credentials_json: ${{ inputs.environment == 'prod' && secrets.PROD_GKE_SERVICE_ACCOUNT_KEY || secrets.DEV_GKE_SERVICE_ACCOUNT_KEY }}
|
||||
|
||||
- uses: google-github-actions/setup-gcloud@v2
|
||||
|
||||
- name: Install gke-gcloud-auth-plugin
|
||||
run: gcloud components install gke-gcloud-auth-plugin --quiet
|
||||
|
||||
- name: Configure Docker for Artifact Registry
|
||||
run: gcloud auth configure-docker us-west2-docker.pkg.dev --quiet
|
||||
|
||||
- name: Get GKE credentials
|
||||
run: |
|
||||
gcloud container clusters get-credentials "${{ steps.env.outputs.cluster }}" \
|
||||
--region "${{ steps.env.outputs.region }}" \
|
||||
--project "${{ steps.env.outputs.project }}"
|
||||
|
||||
- name: Install skaffold
|
||||
run: |
|
||||
curl -fsSLo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
|
||||
sudo install skaffold /usr/local/bin/
|
||||
skaffold version
|
||||
|
||||
- name: Deploy
|
||||
env:
|
||||
SKAFFOLD_DEFAULT_REPO: us-west2-docker.pkg.dev/${{ steps.env.outputs.project }}/deployments
|
||||
run: |
|
||||
if [ "${{ inputs.module }}" = "migrations" ]; then
|
||||
kubectl delete job migrations --ignore-not-found
|
||||
skaffold run -p migrations --tail
|
||||
else
|
||||
skaffold run -p ${{ inputs.environment }} -m ${{ inputs.module }}
|
||||
fi
|
||||
@@ -0,0 +1,22 @@
|
||||
name: Deploy emailnotifierjob
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: "Target environment"
|
||||
required: true
|
||||
type: choice
|
||||
options: [dev, prod]
|
||||
|
||||
concurrency:
|
||||
group: deploy-emailnotifierjob-${{ inputs.environment }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
uses: ./.github/workflows/_deploy.yml
|
||||
with:
|
||||
module: emailnotifierjob
|
||||
environment: ${{ inputs.environment }}
|
||||
secrets: inherit
|
||||
@@ -0,0 +1,22 @@
|
||||
name: Deploy memberreconciler
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: "Target environment"
|
||||
required: true
|
||||
type: choice
|
||||
options: [dev, prod]
|
||||
|
||||
concurrency:
|
||||
group: deploy-memberreconciler-${{ inputs.environment }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
uses: ./.github/workflows/_deploy.yml
|
||||
with:
|
||||
module: memberreconciler
|
||||
environment: ${{ inputs.environment }}
|
||||
secrets: inherit
|
||||
@@ -0,0 +1,22 @@
|
||||
name: Deploy migrations
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: "Target environment"
|
||||
required: true
|
||||
type: choice
|
||||
options: [dev, prod]
|
||||
|
||||
concurrency:
|
||||
group: deploy-migrations-${{ inputs.environment }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
uses: ./.github/workflows/_deploy.yml
|
||||
with:
|
||||
module: migrations
|
||||
environment: ${{ inputs.environment }}
|
||||
secrets: inherit
|
||||
@@ -0,0 +1,22 @@
|
||||
name: Deploy orion
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: "Target environment"
|
||||
required: true
|
||||
type: choice
|
||||
options: [dev, prod]
|
||||
|
||||
concurrency:
|
||||
group: deploy-orion-${{ inputs.environment }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
uses: ./.github/workflows/_deploy.yml
|
||||
with:
|
||||
module: orion
|
||||
environment: ${{ inputs.environment }}
|
||||
secrets: inherit
|
||||
@@ -0,0 +1,22 @@
|
||||
name: Deploy pusher
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: "Target environment"
|
||||
required: true
|
||||
type: choice
|
||||
options: [dev, prod]
|
||||
|
||||
concurrency:
|
||||
group: deploy-pusher-${{ inputs.environment }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
uses: ./.github/workflows/_deploy.yml
|
||||
with:
|
||||
module: pusher
|
||||
environment: ${{ inputs.environment }}
|
||||
secrets: inherit
|
||||
@@ -0,0 +1,22 @@
|
||||
name: Deploy worker (particleprocessorworker)
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: "Target environment"
|
||||
required: true
|
||||
type: choice
|
||||
options: [dev, prod]
|
||||
|
||||
concurrency:
|
||||
group: deploy-worker-${{ inputs.environment }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
uses: ./.github/workflows/_deploy.yml
|
||||
with:
|
||||
module: worker
|
||||
environment: ${{ inputs.environment }}
|
||||
secrets: inherit
|
||||
Reference in New Issue
Block a user