Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: PLT-419: Standart argocd workflows #277

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 56 additions & 27 deletions .github/workflows/argocd-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ name: "ArgoCD: Deploy"
on:
workflow_call:
inputs:
docker_image_version:
required: true
type: string
app_name:
release_name:
required: true
type: string
template_name:
required: false
default: "adala"
type: string
cloud:
required: false
default: "aws"
type: string
cluster:
required: false
default: "dev.heartex.com"
Expand All @@ -21,21 +22,29 @@ on:
required: false
default: "prompt"
type: string
workflow_dispatch:
inputs:
docker_image_version:
description: "Docker image version"
required: true
type: string
app_name:
description: "ArgoCD App name"
override_values:
required: false
default: ""
type: string
workflow_dispatch:
inputs:
release_name:
description: "Release name"
required: true
type: string
template_name:
description: "ArgoCD template name"
description: "Template name"
required: false
default: "adala"
type: string
cloud:
description: "Cloud name"
required: false
default: "aws"
type: string
cluster:
description: "Cluster name"
required: false
Expand All @@ -46,6 +55,15 @@ on:
required: false
default: "prompt"
type: string
docker_image_version:
description: "Docker image version"
required: true
type: string
override_values:
description: "Override values"
required: false
default: ""
type: string

env:
INFRA_REPO: "HumanSignal/infra"
Expand All @@ -54,21 +72,12 @@ jobs:

deploy:
timeout-minutes: 15
runs-on: ubuntu-latest
runs-on: "hs-dev-runner"
outputs:
host: ${{ steps.argocd-wait-app.outputs.url }}
steps:
- uses: hmarr/[email protected]

- name: "GitHub deployment: Start"
id: github-deployment-start
continue-on-error: true
if: github.event.pull_request.head.ref
uses: bobheadxi/deployments@v1
with:
step: start
token: ${{ secrets.GIT_PAT }}
env: ${{ inputs.app_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: Get GitHub user details
id: get-github-user
uses: actions/github-script@v7
Expand Down Expand Up @@ -119,18 +128,38 @@ jobs:
uses: ./.github/actions-hub/actions/argocd-app-create
id: argocd-app
with:
docker_image_tag: "${{ inputs.docker_image_version }}"
release_name: "${{ inputs.app_name }}"
app_name: "${{ inputs.app_name }}-${{ inputs.template_name }}"
release_name: "${{ inputs.release_name }}"
template_name: "${{ inputs.template_name }}"
cloud: "${{ inputs.cloud }}"
cluster: "${{ inputs.cluster }}"
namespace: "${{ inputs.namespace }}"
github_token: ${{ secrets.GIT_PAT }}
docker_image_tag: "${{ inputs.docker_image_version }}"
override_values: "${{ inputs.override_values }}"
github_token: "${{ secrets.GIT_PAT }}"

- name: Git Push
id: push
uses: ./.github/actions-hub/actions/git-push

- name: "GitHub deployment: Start"
id: github-deployment-start
continue-on-error: true
if: github.event.pull_request.head.ref
uses: bobheadxi/deployments@v1
with:
step: start
token: ${{ secrets.GIT_PAT }}
env: ${{ steps.argocd-app.outputs.release_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: Wait for ArgoCD App
uses: ./.github/actions-hub/actions/argocd-app-wait
id: argocd-wait-app
with:
app_name: "${{ steps.argocd-app.outputs.app_name }}"
argocd_url: "${{ env.ARGOCD_URL }}"
argocd_token: "${{ secrets.ARGOCD_DEV_TOKEN }}"

- name: "GitHub deployment: Finish"
id: github-deployment-finish
if: always() && github.event.pull_request.head.ref
Expand All @@ -141,4 +170,4 @@ jobs:
status: ${{ job.status }}
deployment_id: ${{ steps.github-deployment-start.outputs.deployment_id }}
env: ${{ steps.github-deployment-start.outputs.env }}
env_url: "https://${{ steps.argocd-app.outputs.url }}"
env_url: "${{ steps.argocd-wait-app.outputs.url }}"
32 changes: 21 additions & 11 deletions .github/workflows/argocd-destroy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ name: "ArgoCD: Destroy"
on:
workflow_call:
inputs:
app_name:
release_name:
required: true
type: string
template_name:
required: false
default: "adala"
type: string
cloud:
required: false
default: "aws"
type: string
cluster:
required: false
default: "dev.heartex.com"
Expand All @@ -20,15 +24,20 @@ on:
type: string
workflow_dispatch:
inputs:
app_name:
description: "ArgoCD App name"
release_name:
description: "Release name"
required: true
type: string
template_name:
description: "ArgoCD template name"
description: "Template name"
required: false
default: "adala"
type: string
cloud:
description: "Cloud name"
required: false
default: "aws"
type: string
cluster:
description: "Cluster name"
required: false
Expand All @@ -44,7 +53,6 @@ on:
- closed
branches:
- master
- '**'

env:
INFRA_REPO: "HumanSignal/infra"
Expand Down Expand Up @@ -103,23 +111,25 @@ jobs:
username: "${{ steps.get-github-user.outputs.user_name }}"
email: "${{ steps.get-github-user.outputs.user_email }}"

- name: Calculate version
id: version
- name: Details
id: details
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref || github.ref_name }}
run: |
set -x
pretty_branch_name="$(echo -n "${BRANCH_NAME#refs/heads/}" | sed 's#/#-#g' | sed 's#_#-#g'| sed 's#\.#-#g' | tr '[:upper:]' '[:lower:]' | cut -c1-25)"
echo "pretty_branch_name=$pretty_branch_name" >> $GITHUB_OUTPUT
echo "pretty_branch_name=${pretty_branch_name}" >> "${GITHUB_OUTPUT}"
- name: Delete ArgoCD App
uses: ./.github/actions-hub/actions/argocd-app-delete
id: argocd-app
with:
app_name: "${{ inputs.app_name || steps.version.outputs.pretty_branch_name }}-${{ inputs.template_name || 'adala' }}"
release_name: "${{ inputs.release_name || steps.details.outputs.pretty_branch_name }}"
template_name: "${{ inputs.template_name || 'adala' }}"
cloud: "${{ inputs.cloud || 'aws' }}"
cluster: "${{ inputs.cluster || 'dev.heartex.com' }}"
namespace: "${{ inputs.namespace || 'prompt' }}"
github_token: ${{ secrets.GIT_PAT }}
github_token: "${{ secrets.GIT_PAT }}"

- name: Git Push
id: push
Expand All @@ -131,4 +141,4 @@ jobs:
with:
step: delete-env
token: ${{ secrets.GIT_PAT }}
env: ${{ inputs.app_name || steps.version.outputs.pretty_branch_name }}
env: ${{ steps.argocd-app.outputs.app_name }}
19 changes: 14 additions & 5 deletions .github/workflows/argocd-scaledown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
required: false
default: "adala"
type: string
cloud:
required: false
default: "aws"
type: string
cluster:
required: false
default: "dev.heartex.com"
Expand All @@ -29,6 +33,11 @@ on:
required: false
default: "adala"
type: string
cloud:
description: "Cloud name"
required: false
default: "aws"
type: string
cluster:
description: "Cluster name"
required: false
Expand All @@ -44,7 +53,6 @@ on:
- converted_to_draft
branches:
- master
- '**'

env:
INFRA_REPO: "HumanSignal/infra"
Expand Down Expand Up @@ -103,21 +111,22 @@ jobs:
username: "${{ steps.get-github-user.outputs.user_name }}"
email: "${{ steps.get-github-user.outputs.user_email }}"

- name: Calculate version
id: version
- name: Details
id: details
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref || github.ref_name }}
run: |
set -x
pretty_branch_name="$(echo -n "${BRANCH_NAME#refs/heads/}" | sed 's#/#-#g' | sed 's#_#-#g'| sed 's#\.#-#g' | tr '[:upper:]' '[:lower:]' | cut -c1-25)"
echo "pretty_branch_name=$pretty_branch_name" >> $GITHUB_OUTPUT
echo "pretty_branch_name=${pretty_branch_name}" >> "${GITHUB_OUTPUT}"
- name: Scaledown ArgoCD App
uses: ./.github/actions-hub/actions/argocd-app-scaledown
id: argocd-app
with:
release_name: "${{ inputs.release_name || steps.details.outputs.pretty_branch_name }}"
template_name: "${{ inputs.template_name || 'adala' }}"
cloud: "${{ inputs.cloud || 'aws' }}"
cluster: "${{ inputs.cluster || 'dev.heartex.com' }}"
namespace: "${{ inputs.namespace || 'prompt' }}"
github_token: "${{ secrets.GIT_PAT }}"
Expand All @@ -132,5 +141,5 @@ jobs:
with:
step: deactivate-env
token: ${{ secrets.GIT_PAT }}
env: ${{ inputs.release_name || steps.details.outputs.pretty_branch_name }}
env: ${{ steps.argocd-app.outputs.app_name }}
desc: "Environment was scaled down"
4 changes: 2 additions & 2 deletions .github/workflows/cicd-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ jobs:
contents: read
deployments: write
with:
docker_image_version: ${{ needs.build.outputs.image_version }}
app_name: ${{ needs.build.outputs.pretty_branch_name }}
release_name: "${{ needs.build.outputs.pretty_branch_name }}"
docker_image_version: "${{ needs.build.outputs.image_version }}"
secrets: inherit
Loading