Fix envsubst braces #102
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deployment | |
on: | |
push: | |
branches: | |
- main | |
- staging | |
jobs: | |
build-docker: | |
name: Build Docker image | |
environment: ${{ github.ref_name }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out source repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Install doctl | |
uses: digitalocean/action-doctl@v2 | |
with: | |
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | |
- name: Log in to DO Container Registry | |
run: doctl registry login --expiry-seconds 600 | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: registry.digitalocean.com/${{ secrets.DIGITALOCEAN_CONTAINER_REPO }}/discord-bots:${{ github.sha }} | |
cache-from: type=gha | |
cache-to: type=gha | |
target: prod | |
deploy: | |
name: Deploy to Kubernetes | |
environment: ${{ github.ref_name }} | |
runs-on: ubuntu-latest | |
needs: build-docker | |
env: | |
AIRTABLE_API_KEY: ${{ secrets.AIRTABLE_API_KEY }} | |
POLYGONSCAN_API_KEY: ${{ secrets.POLYGONSCAN_API_KEY }} | |
WEB3_PROVIDER_ETH_URL: ${{ secrets.WEB3_PROVIDER_ETH_URL }} | |
WEB3_PROVIDER_POLYGON_URL: ${{ secrets.WEB3_PROVIDER_POLYGON_URL }} | |
DISCORD_BOT_TOKEN_REBASE: ${{ secrets.DISCORD_BOT_TOKEN_REBASE }} | |
DISCORD_BOT_WEBHOOK_REBASE: ${{ secrets.DISCORD_BOT_WEBHOOK_REBASE }} | |
DISCORD_BOT_TOKEN_RUNWAY: ${{ secrets.DISCORD_BOT_TOKEN_RUNWAY }} | |
DISCORD_BOT_TOKEN_DAO_FEE: ${{ secrets.DISCORD_BOT_TOKEN_DAO_FEE }} | |
DISCORD_BOT_TOKEN_DAO_BALANCE: ${{ secrets.DISCORD_BOT_TOKEN_DAO_BALANCE }} | |
DISCORD_BOT_TOKEN_KLIMA_BOND_ALERTS: ${{ secrets.DISCORD_BOT_TOKEN_KLIMA_BOND_ALERTS }} | |
DISCORD_BOT_TOKEN_KLIMA_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_KLIMA_PRICE }} | |
DISCORD_BOT_TOKEN_BCT_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_BCT_PRICE }} | |
DISCORD_BOT_TOKEN_MCO2_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_MCO2_PRICE }} | |
DISCORD_BOT_TOKEN_STAKING_REWARDS: ${{ secrets.DISCORD_BOT_TOKEN_STAKING_REWARDS }} | |
DISCORD_BOT_TOKEN_SUPPLY_CC: ${{ secrets.DISCORD_BOT_TOKEN_SUPPLY_CC }} | |
DISCORD_BOT_TOKEN_INDEX: ${{ secrets.DISCORD_BOT_TOKEN_INDEX }} | |
DISCORD_BOT_TOKEN_RETIREMENT_FEE_INFO: ${{ secrets.DISCORD_BOT_TOKEN_RETIREMENT_FEE_INFO }} | |
DISCORD_BOT_TOKEN_TREASURY_CARBON: ${{ secrets.DISCORD_BOT_TOKEN_TREASURY_CARBON }} | |
DISCORD_BOT_TOKEN_TREASURY_MARKET: ${{ secrets.DISCORD_BOT_TOKEN_TREASURY_MARKET }} | |
DISCORD_BOT_TOKEN_C3_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_C3_PRICE }} | |
DISCORD_BOT_TOKEN_UBO_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_UBO_PRICE }} | |
DISCORD_BOT_TOKEN_MOSS_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_MOSS_PRICE }} | |
DISCORD_BOT_TOKEN_NBO_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_NBO_PRICE }} | |
DISCORD_BOT_TOKEN_NCT_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_NCT_PRICE }} | |
GITHUB_SHA: ${{ github.sha }} | |
DOCKER_IMAGE: registry.digitalocean.com/${{ secrets.DIGITALOCEAN_CONTAINER_REPO }}/discord-bots:${{ github.sha }} | |
steps: | |
- name: Check out source repository | |
uses: actions/checkout@v2 | |
# TODO update doctl to use 2fcbadcb46efd8dca0d93fbef2a3a8394f5981ba with the error code fix | |
- name: Install doctl | |
uses: digitalocean/action-doctl@v2 | |
with: | |
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | |
# k8s Deployment | |
- name: Setup Kustomize | |
uses: imranismail/setup-kustomize@v2.1.0-rc | |
with: | |
kustomize-version: "4.5.4" | |
- name: Update deployment file with image | |
run: sed -i 's|<IMAGE>|'${DOCKER_IMAGE}'|' $GITHUB_WORKSPACE/k8s/base/deployment.yaml | |
- name: Update secret properties with injected secrets | |
run: envsubst < $GITHUB_WORKSPACE/k8s/secret.properties.template > $GITHUB_WORKSPACE/k8s/secret.properties | |
- name: Test | |
run: cat $GITHUB_WORKSPACE/k8s/secret.properties | |
- name: Save DigitalOcean kubeconfig with short-lived credentials | |
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.DIGITALOCEAN_CLUSTER_NAME }} | |
- name: Deploy to DigitalOcean Kubernetes | |
run: kubectl apply -k k8s | |
- name: Verify deployments | |
run: deploy=$(kubectl get deploy -n discord-bots -o name); for i in $deploy; do kubectl -n discord-bots rollout status $i; done |