|
| 1 | +version: '1.0' |
| 2 | + |
| 3 | +stages: |
| 4 | +- Prepare |
| 5 | +- Build |
| 6 | +- Push |
| 7 | +- Deploy |
| 8 | + |
| 9 | +steps: |
| 10 | + main_clone: |
| 11 | + title: "Clone repository" |
| 12 | + type: git-clone |
| 13 | + stage: Prepare |
| 14 | + description: "Initialize" |
| 15 | + repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} |
| 16 | + git: CF-default |
| 17 | + revision: ${{CF_REVISION}} |
| 18 | + |
| 19 | + export: |
| 20 | + title: Export Environment |
| 21 | + stage: Prepare |
| 22 | + image: alpine |
| 23 | + commands: |
| 24 | + - cf_export GIT_BRANCH=${{CF_BRANCH}} |
| 25 | + - cf_export PROJECT=${{CF_REPO_NAME}} |
| 26 | + - cf_export APP_NAME=${{CF_REPO_NAME}} |
| 27 | + - cf_export CHART_NAME=monochart |
| 28 | + - cf_export PIPELINE_ENV=integration |
| 29 | + - cf_export NAMESPACE=pr-${{CF_PULL_REQUEST_NUMBER}}-${{CF_REPO_NAME}} |
| 30 | + - cf_export RELEASE_NAME=pr-${{CF_PULL_REQUEST_NUMBER}}-${{CF_REPO_NAME}} |
| 31 | + - cf_export APP_HOST=pr-${{CF_PULL_REQUEST_NUMBER}}.${{CF_REPO_NAME}}.${{BASE_HOST}} |
| 32 | + - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} |
| 33 | + - cf_export IMAGE_TAG=${{CF_REVISION}} |
| 34 | + |
| 35 | + build_image: |
| 36 | + title: Build image |
| 37 | + stage: Build |
| 38 | + type: build |
| 39 | + description: Build app |
| 40 | + image_name: ${{CF_REPO_NAME}} |
| 41 | + dockerfile: Dockerfile |
| 42 | + no_cache: false |
| 43 | + no_cf_cache: false |
| 44 | + |
| 45 | + push_image_commit: |
| 46 | + title: Push image with commit tag |
| 47 | + stage: Push |
| 48 | + type: push |
| 49 | + candidate: ${{build_image}} |
| 50 | + tags: |
| 51 | + - "${{CF_REVISION}}" |
| 52 | + |
| 53 | + set_github_deployment_status_to_pending: |
| 54 | + title: Set GitHub deployment status to "pending" |
| 55 | + stage: Deploy |
| 56 | + image: cloudposse/github-status-updater |
| 57 | + environment: |
| 58 | + - GITHUB_ACTION=update_state |
| 59 | + - GITHUB_TOKEN=${{GITHUB_TOKEN}} |
| 60 | + - GITHUB_OWNER=${{CF_REPO_OWNER}} |
| 61 | + - GITHUB_REPO=${{CF_REPO_NAME}} |
| 62 | + - GITHUB_REF=${{CF_REVISION}} |
| 63 | + - GITHUB_CONTEXT=Staging Environment |
| 64 | + - GITHUB_STATE=pending |
| 65 | + - GITHUB_DESCRIPTION=Deploying changes to ${{NAMESPACE}} namespace |
| 66 | + - GITHUB_TARGET_URL=http://${{APP_HOST}} |
| 67 | + when: |
| 68 | + condition: |
| 69 | + all: |
| 70 | + githubNotificationsEnabled: "'${{GITHUB_NOTIFICATIONS_ENABLED}}' == 'true'" |
| 71 | + |
| 72 | + deploy_helmfile: |
| 73 | + title: Deploy with helmfile |
| 74 | + stage: Deploy |
| 75 | + image: "${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}}:${{CF_REVISION}}" |
| 76 | + working_directory: /deploy/ |
| 77 | + commands: |
| 78 | + # Announce the release version |
| 79 | + - "echo 'Preparing to deploy ${{CF_REPO_NAME}}:${{CF_RELEASE_TAG}}'" |
| 80 | + # Deploy chart to cluster in a dedicated namespace |
| 81 | + - "/deploy/ctl --namespace=${{NAMESPACE}} rolling" |
| 82 | + |
| 83 | + set_github_deployment_status_to_success: |
| 84 | + title: Set GitHub deployment status to "success" |
| 85 | + stage: Deploy |
| 86 | + image: cloudposse/github-status-updater |
| 87 | + environment: |
| 88 | + - GITHUB_ACTION=update_state |
| 89 | + - GITHUB_TOKEN=${{GITHUB_TOKEN}} |
| 90 | + - GITHUB_OWNER=${{CF_REPO_OWNER}} |
| 91 | + - GITHUB_REPO=${{CF_REPO_NAME}} |
| 92 | + - GITHUB_REF=${{CF_REVISION}} |
| 93 | + - GITHUB_CONTEXT=Staging Environment |
| 94 | + - GITHUB_STATE=success |
| 95 | + - GITHUB_DESCRIPTION=Deployed to ${{NAMESPACE}} namespace |
| 96 | + - GITHUB_TARGET_URL=http://${{APP_HOST}} |
| 97 | + when: |
| 98 | + condition: |
| 99 | + all: |
| 100 | + githubNotificationsEnabled: "'${{GITHUB_NOTIFICATIONS_ENABLED}}' == 'true'" |
| 101 | + |
| 102 | + send_slack_notification: |
| 103 | + title: Send notification to Slack channel |
| 104 | + stage: Deploy |
| 105 | + image: cloudposse/build-harness:${{BUILD_HARNESS_VERSION}} |
| 106 | + commands: |
| 107 | + - make codefresh/notify/slack/deploy/webapp |
0 commit comments