Skip to content

Commit

Permalink
add github workflows to deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
k-kondratuk committed Jun 10, 2024
1 parent 969f004 commit 7637a36
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/deploy_to_env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Deploy to env

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
on:
workflow_dispatch:
inputs:
environment:
description: Environment to deploy to
type: environment
required: true
version:
description: Version to upload and deploy
type: string
workflow_call:
inputs:
env:
description: Environment to deploy to
type: string
required: true
region:
description: region to deploy to
type: string
required: true
account:
description: account to deploy to
type: string
required: true
version:
description: Version to upload and deploy
type: string
required: true
env:
VERSION: ${{inputs.version || github.sha}}
env: ${{ vars.ENV || inputs.env }}
region: ${{ vars.REGION || inputs.region }}
account: ${{ vars.ACCOUNT || inputs.account }}
jobs:
set-vars:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: print env vars
id: export-env-vars
run: |
echo "$account"
echo "$region"
echo "$env"
echo "region=$region" >> "$GITHUB_OUTPUT"
echo "account=$account" >> "$GITHUB_OUTPUT"
echo "env=$env" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
outputs:
region: ${{ steps.export-env-vars.outputs.region }}
account: ${{ steps.export-env-vars.outputs.account }}
env: ${{ steps.export-env-vars.outputs.env }}
version: ${{ steps.export-env-vars.outputs.version }}
upload:
needs: set-vars
name: Build and push image
uses: fetch-rewards/common-workflows/.github/workflows/publish-ecr.yml@main
with:
service-name: ${{ vars.SERVICE_NAME }}
version-tag: ${{ needs.set-vars.outputs.version }}
fsd-diff:
needs: [upload, set-vars]
name: Diff to ${{ inputs.environment }}
uses: fetch-rewards/common-workflows/.github/workflows/run-fsd.yml@main
with:
cmd_args: service eks diff --env ${{ needs.set-vars.outputs.env }} --region ${{ needs.set-vars.outputs.region }} --account ${{ needs.set-vars.outputs.account }} --version ${{ needs.set-vars.outputs.version }} --skip-ephemeris ${{ vars.SERVICE_NAME }}.yml
fsd-deploy:
needs: [upload, set-vars, fsd-diff]
name: Deploy to ${{ inputs.environment }}
uses: fetch-rewards/common-workflows/.github/workflows/run-fsd.yml@main
with:
cmd_args: service eks deploy --env ${{ needs.set-vars.outputs.env }} --region ${{ needs.set-vars.outputs.region }} --account ${{ needs.set-vars.outputs.account }} --version ${{ needs.set-vars.outputs.version }} --skip-ephemeris --source-legacy ${{ vars.SERVICE_NAME }}.yml
25 changes: 25 additions & 0 deletions .github/workflows/on_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: On main
permissions:
id-token: write # This is required for requesting the JWT
contents: write # This is required for actions/checkout

on:
workflow_dispatch:
push:
branches:
- main
jobs:
increment-version:
name: Increment release version tag
uses: fetch-rewards/common-workflows/.github/workflows/increment-semantic-version.yml@main
with:
version-type: patch
deploy-prod:
name: Deploy prod env
needs: [increment-version]
uses: fetch-rewards/build-your-own-radar/.github/workflows/deploy_to_env.yml@main
with:
env: prod
account: prod-services
region: us-east-1
version: ${{ needs.increment-version.outputs.new-tag }}
28 changes: 28 additions & 0 deletions .github/workflows/on_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: On pr
permissions:
id-token: write # This is required for requesting the JWT
contents: write # This is required for actions/checkout
actions: write
discussions: write
pull-requests: write
packages: write

on:
pull_request:
types: [opened, reopened, edited]
jobs:
fsd-diff:
name: Fsd diff
uses: fetch-rewards/common-workflows/.github/workflows/fsd-diff.yml@main
with:
config: ${{ vars.SERVICE_NAME }}.yml
region: us-east-1
env: dev
deploy-prod:
name: Deploy stage env
needs: [fsd-diff]
uses: fetch-rewards/build-your-own-radar/.github/workflows/deploy_to_env.yml@main
with:
env: stage
account: stage-services
region: us-east-1

0 comments on commit 7637a36

Please sign in to comment.