Skip to content

Commit

Permalink
[.github] - feature: enhance deployment workflow with regional deploy…
Browse files Browse the repository at this point in the history
…ment options

 - Include input options in workflow_dispatch to specify deployment regions
 - Add conditional matrix generation for build jobs based on input regions
 - Separate build and notify tasks to improve workflow readability and function
 - Implement conditions for deployment job to run only on main branch
 - Update Slack notification steps to use dynamic thread timestamps and region specifics
  • Loading branch information
JulesBelveze committed Jan 3, 2025
1 parent 9fc6c81 commit 40c9c58
Showing 1 changed file with 59 additions and 10 deletions.
69 changes: 59 additions & 10 deletions .github/workflows/deploy-alerting-temporal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,33 @@ name: Deploy Alerting Temporal

on:
workflow_dispatch:
inputs:
regions:
description: "Regions to deploy to"
required: true
default: "us-central1"
type: choice
options:
- "us-central1"
- "europe-west1"
- "all"

concurrency:
group: deploy_alerting_temporal
cancel-in-progress: false

env:
GCLOUD_PROJECT_ID: ${{ secrets.GCLOUD_PROJECT_ID }}
IMAGE_NAME: alerting-temporal

jobs:
build-and-deploy:
notify-start:
runs-on: ubuntu-latest
outputs:
thread_ts: ${{ steps.build_message.outputs.thread_ts }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- uses: actions/checkout@v3
- name: Get short sha
id: short_sha
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
Expand All @@ -32,19 +43,56 @@ jobs:
channel: ${{ secrets.SLACK_CHANNEL_ID }}
slack_token: ${{ secrets.SLACK_BOT_TOKEN }}

create-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: |
if [ "${{ github.event.inputs.regions }}" = "all" ]; then
echo "matrix=[\"us-central1\",\"europe-west1\"]" >> $GITHUB_OUTPUT
else
echo "matrix=[\"${{ github.event.inputs.regions }}\"]" >> $GITHUB_OUTPUT
fi
build:
needs: [notify-start, create-matrix]
runs-on: ubuntu-latest
strategy:
matrix:
region: ${{ fromJson(needs.create-matrix.outputs.matrix) }}
fail-fast: true

steps:
- uses: actions/checkout@v3
- name: Get short sha
id: short_sha
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: "Authenticate with Google Cloud"
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.GCLOUD_SA_KEY }}"

- name: Build the image on Cloud Build
- name: Build image for ${{ matrix.region }}
run: |
chmod +x ./k8s/cloud-build.sh
./k8s/cloud-build.sh \
--image-name=alerting-temporal \
--image-name=$IMAGE_NAME \
--dockerfile-path=./Dockerfile \
--working-dir=./alerting/temporal/ \
--region=us-central1
--region=${{ matrix.region }}
deploy:
if: github.ref == 'refs/heads/main'
needs: [notify-start, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get short sha
id: short_sha
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Generate a token
id: generate-token
Expand All @@ -66,10 +114,10 @@ jobs:
repo: 'dust-infra',
event_type: 'trigger-component-deploy',
client_payload: {
regions: 'us-central1',
regions: '${{ github.event.inputs.regions }}',
component: 'alerting-temporal',
image_tag: '${{ steps.short_sha.outputs.short_sha }}',
slack_thread_ts: "${{ steps.build_message.outputs.thread_ts }}",
slack_thread_ts: "${{ needs.notify-start.outputs.thread_ts }}",
slack_channel: '${{ secrets.SLACK_CHANNEL_ID }}'
}
});
Expand All @@ -79,8 +127,9 @@ jobs:
uses: ./.github/actions/slack-notify
with:
step: "failure"
blocked: ${{ steps.check_deployment_blocked.outputs.blocked }}
component: "alerting-temporal"
image_tag: ${{ steps.short_sha.outputs.short_sha }}
channel: ${{ secrets.SLACK_CHANNEL_ID }}
slack_token: ${{ secrets.SLACK_BOT_TOKEN }}
thread_ts: "${{ steps.build_message.outputs.thread_ts }}"
thread_ts: "${{ needs.notify-start.outputs.thread_ts }}"

0 comments on commit 40c9c58

Please sign in to comment.