Skip to main content
Latest Documentation
This is the latest documentation for the Cloud Posse Reference Architecture. To determine which version you're currently using, please see Version Identification.

GitHub Action: deploy-argocd

Deploy on Kubernetes with ArgoCD

Introduction

Deploy on Kubernetes with Helm/HelmFile and ArgoCD.

Usage

Deploy environment

  name: Pull Request
on:
pull_request:
branches: [ 'main' ]
types: [opened, synchronize, reopened]

jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: preview
url: ${{ steps.deploy.outputs.webapp-url }}
steps:

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-[email protected]
with:
aws-region: us-west-2
role-to-assume: arn:aws:iam::111111111111:role/preview
role-session-name: deploy

- name: Deploy
uses: cloudposse/github-action-deploy-argocd@main
id: deploy
with:
cluster: https://github.com/cloudposse/argocd-deploy-non-prod-test/blob/main/plat/ue2-sandbox/apps
toolchain: helmfile
environment: preview
namespace: preview
application: test-app
github-pat: ${{ secrets.GITHUB_AUTH_PAT }}
repository: ${{ github.repository }}
ref: ${{ github.event.pull_request.head.ref }}
image: nginx
image-tag: latest
operation: deploy
debug: false
synchronously: true
deployment-id: ${{ github.run_id }}-${{ github.run_attempt }}

Destroy environment

  name: Pull Request
on:
pull_request:
branches: [ 'main' ]
types: [closed]

jobs:
destroy:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-[email protected]
with:
aws-region: us-west-2
role-to-assume: arn:aws:iam::111111111111:role/preview
role-session-name: destroy

- name: Destroy
uses: cloudposse/github-action-deploy-helmfile@main
id: destroy
with:
cluster: https://github.com/cloudposse/argocd-deploy-non-prod-test/blob/main/plat/ue2-sandbox/apps
toolchain: helmfile
environment: preview
namespace: preview
application: test-app
github-pat: ${{ secrets.GITHUB_AUTH_PAT }}
repository: ${{ github.repository }}
ref: ${{ github.event.pull_request.head.ref }}
image: "<none>"
image-tag: "<none>"
operation: destroy
debug: false

Deduping ArgoCD notifications per deploy attempt

ArgoCD's notification oncePer trigger dedupes on whichever field you point it at. Keying it on the application commit means a rollback — replaying a commit ArgoCD has already notified for — is silently suppressed, and the rollback reports no status at all.

Pass deployment-id a value that is unique per deploy attempt rather than per code state, and point oncePer at it instead:

  - name: Deploy
uses: cloudposse/github-action-deploy-argocd@main
with:
# ...
deployment-id: ${{ github.run_id }}-${{ github.run_attempt }}

The value is written to the generated config.yaml alongside the rest of the deploy metadata:

  app_repository: acme/example-app
app_commit: 6e6a0e1b0e0c4b2a9f1d3c5e7a9b1d3f5a7c9e1b
app_hostname: https://example-app.example.com
name: preview.example-app
namespace: preview
manifests: plat/ue2-sandbox/apps/preview/example-app/manifests
deployment_id: "12345678901-2"

The input is optional. Left at its empty default, the deployment_id key is omitted from config.yaml entirely, so callers that do not set it get byte-identical output.

Inputs

NameDescriptionDefaultRequired
applicationApplication nameN/Atrue
aws-regionAWS regionus-east-1false
check-retry-countCheck retry count (for synchronously mode)5false
check-retry-intervalCheck retry interval (in seconds) (for synchronously mode)10false
clusterCluster nameN/Atrue
commit-retry-countCommit retry count4false
commit-retry-intervalCommit retry interval (in seconds)10false
commit-status-github-tokenGithub token to access the app repository. Defaults to github-pat if not set.N/Afalse
commit-timeoutCommit timeout (in seconds)60false
debugDebug modefalsefalse
deployment-idUnique identifier for this deploy attempt (for example, the GitHub run ID joined with the run attempt). When set, it is written to config.yaml as deployment\_id, which lets ArgoCD dedupe notifications per deploy attempt instead of per commit. Left unset, the key is omitted from config.yaml.false
environmentHelmfile environmentpreviewfalse
github-patGithub PAT to access argocd configuration repositoryN/Atrue
gitref-shaGit SHA (Depricated. Use ref instead)false
helm-argsAdditional helm argumentsfalse
helm-dependency-buildRun helm dependency build, only for helm toolchain, true or falsefalsefalse
helm-versionHelm versionv3.20.1false
helmfile-argsAdditional helmfile argumentsfalse
helmfile-versionHelmfile versionv1.4.3false
imageDocker imageN/Atrue
image-tagDocker image tagN/Atrue
kube-versionKubernetes version for helm/helmfile rendering (e.g. 1.28). When provided, skips SSM metadata lookup via chamber.false
namespaceKubernetes namespaceN/Atrue
operationOperation with helmfiles. (valid options - deploy, destroy)deploytrue
pathThe path where lives the helmfile or helm chart.N/Atrue
refGit refN/Atrue
release_label_nameThe name of the label used to describe the helm releasereleasefalse
repositoryApplication GitHub repository full nameN/Atrue
ssm-pathSSM path to read environment secretsfalse
synchronouslyWait until ArgoCD successfully apply the changesfalsefalse
toolchainToolchain ('helm', 'helmfile')helmfilefalse
values_fileHelm values file, this can be a single file or a comma separated list of filesfalse

Outputs

NameDescription
shaGit commit SHA into argocd repo
webapp-urlWeb Application url