Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
Example application for Codefresh CI/CD demonstrations.

Contact <hello@cloudposse.com>

26 changes: 20 additions & 6 deletions codefresh/destroy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@ stages:

steps:
main_clone:
type: pending-approval
title: Destory staging environment?
title: Wait
stage: Destroy
image: codefresh/cli:latest
commands:
- codefresh get builds --pipeline=destroy --pipeline=pull-request --branch=${{CF_BRANCH}} --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id'
retry:
maxAttempts: 10
delay: 20
exponentialFactor: 1.1
when:
condition:
any:
deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == false"
validatePRAction: "'${{CF_PULL_REQUEST_ACTION}}' == 'closed'"

destroy:
title: Destroy namespace
Expand All @@ -16,11 +28,13 @@ steps:
environment:
- NAMESPACE=pr-${{CF_PULL_REQUEST_NUMBER}}-${{CF_REPO_NAME}}
commands:
- "apk add kubectl"
- "kubectl config use-context ${{KUBE_CONTEXT}}"
- "make helm/delete/namespace"
- "make helm/delete/namespace/empty"
when:
steps:
- name: main_clone
on:
- approved
condition:
any:
deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == false"
validatePRAction: "'${{CF_PULL_REQUEST_ACTION}}' == 'closed'"

25 changes: 25 additions & 0 deletions codefresh/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ steps:
when:
condition:
all:
deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == true"
githubNotificationsEnabled: "'${{GITHUB_NOTIFICATIONS_ENABLED}}' == 'true'"

push_image_commit:
Expand All @@ -108,6 +109,21 @@ steps:
tags:
- "${{CF_REVISION}}"

wait:
title: Wait
stage: Deploy
image: codefresh/cli:latest
commands:
- codefresh get builds --pipeline=destroy --pipeline=pull-request --branch=${{CF_BRANCH}} --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id'
retry:
maxAttempts: 10
delay: 20
exponentialFactor: 1.1
when:
condition:
any:
deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == true"

deploy_helmfile:
title: Deploy with helmfile
stage: Deploy
Expand All @@ -118,6 +134,10 @@ steps:
- "echo 'Preparing to deploy ${{CF_REPO_NAME}}:${{CF_RELEASE_TAG}}'"
# Deploy chart to cluster in a dedicated namespace
- "/deploy/ctl --namespace=${{NAMESPACE}} rolling"
when:
condition:
any:
deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == true"

set_github_deployment_status_to_success:
title: Set GitHub deployment status to "success"
Expand All @@ -136,6 +156,7 @@ steps:
when:
condition:
all:
deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == true"
githubNotificationsEnabled: "'${{GITHUB_NOTIFICATIONS_ENABLED}}' == 'true'"

send_slack_notification:
Expand All @@ -151,4 +172,8 @@ steps:
- GIT_BRANCH_TAG=${{CF_BRANCH_TAG_NORMALIZED}}
commands:
- make codefresh/notify/slack/deploy/webapp GIT_COMMIT_TIMESTAMP=$((${{CF_BUILD_TIMESTAMP}}/1000))
when:
condition:
any:
deployLabel: "match('${{CF_PULL_REQUEST_LABELS}}', 'deploy', false) == true"