Skip to content
Open
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
75 changes: 51 additions & 24 deletions .github/workflows/cd_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ on:
image:
required: true
type: string
argocd_app_name:
argocd_app_names:
required: true
type: string
deploy_dirs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we need multiple deploy dirs.

Can you gave a example of how the file structure would look with this change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this will work fine too:

global service:

deploys/
  base/
  overlays/
    euc1-testing/
    euc1-staging/
    euc1/
    euw1/

sharded service:

deploys/
  base/
  overlays/
    euc1-testing/
    euc1-staging/
    euc1-shared01/
    euc1-shared02/
    euw1-agents01/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multiple deploy dirs are for multiple apps in the same cluster

deploy-app1/
  base/
  overlays/
    euc1-testing/
deploy-app2/
  base/
  overlays/
    euc1-testing/

required: false
type: string
default: '["deploy"]'
dockle_whitelist:
required: false
type: string
Expand Down Expand Up @@ -44,7 +48,7 @@ jobs:
uses: rtCamp/action-slack-notify@v2
if: failure() && (github.ref_name == 'development' || github.ref_name == 'master' || github.ref_name == 'production')
env:
SLACK_CHANNEL: taas-dev
SLACK_CHANNEL: taas-github
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think failed deploys should be kept in #taas-dev

Github channel is spammed allot by github stuff and this would easily drown

SLACK_COLOR: danger
SLACK_MESSAGE: |
Build job on *${{ github.ref_name }}* has failed for ${{ github.repository }}
Expand All @@ -53,7 +57,7 @@ jobs:
SLACK_WEBHOOK: ${{ secrets.FAILURE_SLACK_WEBHOOK }}
SLACK_ICON: https://github.com/GETProtocolLab.png?size=48

deploy-argocd:
update-kustomize:
runs-on: [self-hosted, ubuntu20.04-self]
needs: build
concurrency:
Expand All @@ -62,26 +66,18 @@ jobs:
if: github.ref_name == 'development' || github.ref_name == 'master' || github.ref_name == 'production'
steps:
- id: argocd
name: Select overlay
shell: bash
run: |
if [ "$GIT_REF" == "development" ]; then
echo ::set-output name=server-url::argocd.euc1.t.get-protocol.dev
echo ::set-output name=token::$EUC1TESTING_TOKEN
echo ::set-output name=overlay::deploy/overlays/euc1-testing
echo ::set-output name=overlay::overlays/euc1-testing
elif [ "$GIT_REF" == "master" ]; then
echo ::set-output name=server-url::argocd.euc1.s.get-protocol.dev
echo ::set-output name=token::$EUC1STAGING_TOKEN
echo ::set-output name=overlay::deploy/overlays/euc1-staging
echo ::set-output name=overlay::overlays/euc1-staging
elif [ "$GIT_REF" == "production" ]; then
echo ::set-output name=server-url::argocd.euc1.get-protocol.cloud
echo ::set-output name=token::$EUC1_TOKEN
echo ::set-output name=overlay::deploy/overlays/euc1
echo ::set-output name=overlay::overlays/euc1
fi
env:
GIT_REF: ${{ github.ref_name }}
EUC1TESTING_TOKEN: ${{ secrets.ARGOCD_EUC1TESTING_API_AUTH }}
EUC1STAGING_TOKEN: ${{ secrets.ARGOCD_EUC1STAGING_API_AUTH }}
EUC1_TOKEN: ${{ secrets.ARGOCD_EUC1_API_AUTH }}

- name: Generate token
id: generate_token
Expand All @@ -97,36 +93,67 @@ jobs:
with:
kustomize-version: "4.4.0"

- uses: actions/setup-node@v3
with:
node-version: 16

- name: Update overlay with new image tag
run: |
cd $TARGET
kustomize edit set image $IMAGE=:$TAG
cat kustomization.yml
jq '.[]' -r <<< $DEPLOY_DIRS | while read i; do
cd $GITHUB_WORKSPACE/$i/$TARGET
kustomize edit set image $IMAGE=:$TAG
cat kustomization.yml
npx prettier --write .
done
shell: bash
env:
TARGET: ${{ steps.argocd.outputs.overlay }}
IMAGE: ${{ inputs.image }}
TAG: ${{ github.sha }}

- uses: actionsx/prettier@v2
with:
args: --write ${{ steps.argocd.outputs.overlay }}/kustomization.yml
DEPLOY_DIRS: ${{ inputs.deploy_dirs }}

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[skip ci] Deploy ${{ github.ref_name }} (${{ github.sha }}) to ${{ steps.argocd.outputs.overlay }}"
deploy-argocd:
runs-on: [self-hosted, ubuntu20.04-self]
needs: "update-kustomize"
strategy:
fail-fast: false
matrix:
APP_NAME: ${{ fromJSON(inputs.argocd_app_names) }}
steps:
- id: argocd
shell: bash
run: |
if [ "$GIT_REF" == "development" ]; then
echo ::set-output name=server-url::argocd.euc1.t.get-protocol.dev
echo ::set-output name=token::$EUC1TESTING_TOKEN
elif [ "$GIT_REF" == "master" ]; then
echo ::set-output name=server-url::argocd.euc1.s.get-protocol.dev
echo ::set-output name=token::$EUC1STAGING_TOKEN
elif [ "$GIT_REF" == "production" ]; then
echo ::set-output name=server-url::argocd.euc1.get-protocol.cloud
echo ::set-output name=token::$EUC1_TOKEN
fi
env:
GIT_REF: ${{ github.ref_name }}
EUC1TESTING_TOKEN: ${{ secrets.ARGOCD_EUC1TESTING_API_AUTH }}
EUC1STAGING_TOKEN: ${{ secrets.ARGOCD_EUC1STAGING_API_AUTH }}
EUC1_TOKEN: ${{ secrets.ARGOCD_EUC1_API_AUTH }}

- run: docker run argoproj/argocd argocd app sync ${{ inputs.argocd_app_name }} --grpc-web --server $SERVER --auth-token $AUTH_TOKEN --prune
- run: docker run argoproj/argocd argocd app sync $APP_NAME --grpc-web --server $SERVER --auth-token $AUTH_TOKEN --prune
env:
SERVER: ${{ steps.argocd.outputs.server-url }}
AUTH_TOKEN: ${{ steps.argocd.outputs.token }}
APP_NAME: ${{ matrix.APP_NAME }}

# Only triggers if this job fails
- name: Failure Slack Notification
uses: rtCamp/action-slack-notify@v2
if: ${{ failure() }}
env:
SLACK_CHANNEL: taas-dev
SLACK_CHANNEL: taas-github
SLACK_COLOR: danger
SLACK_MESSAGE: |
Deploy job on *${{ github.ref_name }}* has failed for ${{ github.repository }}
Expand Down