Merge pull request #344 from tattle-made/hotfix #88
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 to Production | |
permissions: | |
contents: read | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
changes: | |
runs-on: ubuntu-latest | |
outputs: | |
api: ${{ steps.filter.outputs.api}} | |
docs: ${{ steps.filter.outputs.docs }} | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
ref: development | |
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | |
id: filter | |
with: | |
filters: | | |
api: | |
- 'src/api/**/*' | |
docs: | |
- 'docs/**/*' | |
api: | |
runs-on: ubuntu-latest | |
needs: changes | |
if: ${{ needs.changes.outputs.api == 'true' }} | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
ref: main | |
- name: Declare some variables | |
id: vars | |
shell: bash | |
run: | | |
echo "setting variables" | |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
pwd | |
ls | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3.2.0 | |
- name: Login to Docker Hub | |
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v.3.1.0 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push amd64 | |
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 | |
with: | |
context: "{{defaultContext}}:src/" | |
file: Dockerfile | |
platforms: linux/amd64 | |
build-args: | | |
"UID=1000" | |
"GID=1000" | |
push: true | |
tags: tattletech/feluda-server:${{ steps.vars.outputs.sha_short }} | |
- name: deploy to cluster | |
uses: steebchen/kubectl@7c4c70d551952e40881998b840e16d4d9824a54f # v2.1.1 | |
with: # defaults to latest kubectl binary version | |
config: ${{ secrets.PROD_KUBE_CONFIG_DATA }} | |
command: set image --record deployment/feluda-server feluda-server=tattletech/feluda-server:${{ steps.vars.outputs.sha_short }} | |
- name: verify deployment | |
uses: steebchen/kubectl@7c4c70d551952e40881998b840e16d4d9824a54f # v2.1.1 | |
with: | |
config: ${{ secrets.PROD_KUBE_CONFIG_DATA }} | |
version: v1.21.0 # specify kubectl binary version explicitly | |
command: rollout status deployment/feluda-server | |
docs: | |
runs-on: ubuntu-latest | |
needs: changes | |
if: ${{ needs.changes.outputs.docs == 'true' }} | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
ref: main | |
- name: "Setup Node version" | |
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | |
with: | |
node-version: 16.20.2 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ap-south-1 | |
- name: Install Packages | |
run: | | |
cd docs/ | |
npm ci --legacy-peer-deps | |
- name: Build Site | |
run: | | |
cd docs/ | |
npm run build | |
- name: Deploy Site | |
run: | | |
cd docs/ | |
npm run deploy | |
notify: | |
runs-on: ubuntu-latest | |
needs: [api, docs] | |
if: ${{ always() }} | |
steps: | |
- name: Notify on Slack | |
uses: rtCamp/action-slack-notify@b24d75fe0e728a4bf9fc42ee217caa686d141ee8 # v2.2.1 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_MESSAGE: "Deploy Feluda Production" | |
SLACK_TITLE: "Deploy Feluda Production workflow complete" | |
SLACK_COLOR: "#020637" | |
SLACK_ICON: https://tattle-media.s3.amazonaws.com/monogram-dark.svg | |