|
11 | 11 |
|
12 | 12 | env:
|
13 | 13 | IMAGE_NAME: penn-chime
|
| 14 | + DEPLOY_PUSH_BRANCH: develop |
| 15 | + # Required for action steebchen/kubectl |
| 16 | + KUBE_CONFIG_DATA: ${{ secrets.kubeconfig_data_preprod }} |
14 | 17 |
|
15 | 18 | jobs:
|
16 | 19 | # Run tests.
|
|
66 | 69 |
|
67 | 70 | docker tag image $IMAGE_ID:$VERSION
|
68 | 71 | docker push $IMAGE_ID:$VERSION
|
| 72 | +
|
| 73 | + deploy-preprod: |
| 74 | + |
| 75 | + needs: push |
| 76 | + if: github.event_name == 'push' |
| 77 | + runs-on: ubuntu-latest |
| 78 | + |
| 79 | + steps: |
| 80 | + - uses: actions/checkout@v2 |
| 81 | + with: |
| 82 | + fetch-depth: 0 # Needed for proper rebase |
| 83 | + - name: Update application manifest |
| 84 | + run: | |
| 85 | + # Strip git ref prefix from version |
| 86 | + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') |
| 87 | +
|
| 88 | + # Strip "v" prefix from tag name |
| 89 | + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') |
| 90 | +
|
| 91 | + # Update image version in application manifest |
| 92 | + sed -Ei "s,(- image: docker.pkg.github.com)(.*),\1/${{ github.repository }}/$IMAGE_NAME:$VERSION," k8s/app.yaml |
| 93 | +
|
| 94 | + # Show updated manifest file |
| 95 | + cat k8s/app.yaml |
| 96 | +
|
| 97 | + - name: Deploy to preprod |
| 98 | + |
| 99 | + with: |
| 100 | + args: apply -f k8s/app.yaml |
| 101 | + |
| 102 | + - name: Wait for deploy to complete |
| 103 | + |
| 104 | + with: |
| 105 | + args: -n chime rollout status deployment.v1.apps/chime |
| 106 | + |
| 107 | + - name: Show completed deployment |
| 108 | + |
| 109 | + with: |
| 110 | + args: -n chime get deployment chime -o yaml |
| 111 | + |
| 112 | + - name: Push manifest update |
| 113 | + uses: github-actions-x/[email protected] |
| 114 | + with: |
| 115 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 116 | + push-branch: ${{ env.DEPLOY_PUSH_BRANCH }} |
| 117 | + commit-message: Deploy version ${VERSION} to preprod |
| 118 | + rebase: 'true' |
| 119 | + name: Chime CI |
| 120 | + |
0 commit comments