Deploy (main -> production) by @orangewolf #40
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: "Deploy" | |
run-name: Deploy (${{ github.ref_name }} -> ${{ inputs.environment }}) by @${{ github.actor }} | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Deploy to Environment' | |
required: true | |
default: 'staging' | |
type: choice | |
options: | |
- staging | |
- production | |
debug_enabled: | |
type: boolean | |
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' | |
required: false | |
default: false | |
env: | |
REGISTRY: ghcr.io | |
EKS_CLUSTER_NAME: r2-atla-dl | |
AWS_REGION: us-west-2 | |
jobs: | |
deployment: | |
runs-on: ubuntu-latest | |
container: dtzar/helm-kubectl:3.9.4 | |
environment: ${{ inputs.environment }} | |
env: | |
HELM_EXPERIMENTAL_OCI: 1 | |
HELM_RELEASE_NAME: ${{ github.event.repository.name }}-${{ inputs.environment }} | |
KUBE_NAMESPACE: ${{ github.event.repository.name }}-${{ inputs.environment }} | |
HELM_EXTRA_ARGS: > | |
--values ops/${{ inputs.environment }}-deploy.yaml | |
KUBECONFIG_FILE: ${{ secrets.KUBECONFIG_FILE }} | |
KUBECONFIG: ./kubeconfig.yml | |
ADMIN_EMAIL: ${{ secrets.ADMIN_EMAIL }} | |
ADMIN_PASSWORD: ${{ secrets.ADMIN_PASSWORD }} | |
APP_KEY: ${{ secrets.APP_KEY }} | |
CLIENT_ID: ${{ secrets.CLIENT_ID }} | |
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} | |
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} | |
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
GOOGLE_FONTS_KEY: ${{ secrets.GOOGLE_FONTS_KEY }} | |
GOOGLE_OAUTH_PRIVATE_KEY_SECRET: ${{ secrets.GOOGLE_OAUTH_PRIVATE_KEY_SECRET }} | |
GOOGLE_OAUTH_PRIVATE_KEY_VALUE: ${{ secrets.GOOGLE_OAUTH_PRIVATE_KEY_VALUE }} | |
GOOGLE_ANALYTICS_ID: ${{ secrets.GOOGLE_ANALYTICS_ID }} | |
IA_PASSWORD: ${{ secrets.IA_PASSWORD }} | |
MARIADB_PASSWORD: ${{ secrets.MARIADB_PASSWORD }} | |
MARIADB_ROOT_PASSWORD: ${{ secrets.MARIADB_ROOT_PASSWORD }} | |
MAIL_PASS: ${{ secrets.MAIL_PASS }} | |
MYSQL_PASSWORD: ${{ secrets.MARIADB_PASSWORD }} | |
MYSQL_ROOT_PASSWORD: ${{ secrets.MARIADB_ROOT_PASSWORD }} | |
NEGATIVE_CAPTCHA_SECRET: ${{ secrets.NEGATIVE_CAPTCHA_SECRET }} | |
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }} | |
NEXT_PUBLIC_TOKEN: ${{ secrets.NEXT_PUBLIC_TOKEN }} | |
PAPERTRAIL_API_TOKEN: ${{ secrets.PAPERTRAIL_API_TOKEN }} | |
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | |
RAILS_SECRET_TOKEN: ${{ secrets.RAILS_SECRET_TOKEN }} | |
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }} | |
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }} | |
SENDGRID_PASSWORD: ${{ secrets.SENDGRID_PASSWORD }} | |
SLACK_CLIENT_ID: ${{ secrets.SLACK_CLIENT_ID}} | |
SLACK_CLIENT_SECRET: ${{ secrets.SLACK_CLIENT_SECRET }} | |
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }} | |
SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }} | |
SOLR_ADMIN_PASSWORD: ${{ secrets.SOLR_ADMIN_PASSWORD }} | |
SQUARE_ACCESS_TOKEN: ${{ secrets.SQUARE_ACCESS_TOKEN }} | |
SQUARE_WEBHOOK_SIGNATURE_KEY: ${{ secrets.SQUARE_WEBHOOK_SIGNATURE_KEY }} | |
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }} | |
WORDPRESS_PASSWORD: ${{ secrets.WORDPRESS_PASSWORD }} | |
steps: | |
- id: setup | |
name: Setup | |
uses: scientist-softserv/actions/[email protected] | |
with: | |
tag: ${{ inputs.tag }} | |
image_name: ${{ inputs.image_name }} | |
token: ${{ secrets.CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }} | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{env.AWS_REGION}} | |
- name: Setup tmate session | |
uses: mxschmitt/action-tmate@v3 | |
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} | |
with: | |
limit-access-to-actor: true | |
- name: Do deploy with solr image | |
if: ${{ inputs.deploy-solr-image }} | |
run: | | |
aws eks update-kubeconfig --name $EKS_CLUSTER_NAME --region $AWS_REGION --kubeconfig $KUBECONFIG | |
DOLLAR=$ envsubst < ops/${{ inputs.environment }}-deploy.tmpl.yaml > ops/${{ inputs.environment }}-deploy.yaml; | |
export DEPLOY_TAG=${TAG}; | |
export DEPLOY_IMAGE=ghcr.io/${REPO_LOWER}; | |
export WORKER_IMAGE=ghcr.io/${REPO_LOWER}/worker; | |
export SOLR_IMAGE=ghcr.io/${REPO_LOWER}/solr; | |
./bin/helm_deploy ${{ inputs.environment || format('{0}-{1}', github.event.repository.name, inputs.environment) }} ${{ inputs.environment || format('{0}-{1}', github.event.repository.name, inputs.environment) }} | |
- name: Do deploy | |
if: ${{ inputs.deploy-solr-image }} == 'false' | |
run: | | |
aws eks update-kubeconfig --name $EKS_CLUSTER_NAME --region $AWS_REGION --kubeconfig $KUBECONFIG | |
DOLLAR=$ envsubst < ops/${{ inputs.environment }}-deploy.tmpl.yaml > ops/${{ inputs.environment }}-deploy.yaml; | |
export DEPLOY_TAG=${TAG}; | |
export DEPLOY_IMAGE=ghcr.io/${REPO_LOWER}; | |
export WORKER_IMAGE=ghcr.io/${REPO_LOWER}/worker; | |
./bin/helm_deploy ${{ inputs.environment || format('{0}-{1}', github.event.repository.name, inputs.environment) }} ${{ inputs.environment || format('{0}-{1}', github.event.repository.name, inputs.environment) }} |