Skip to content

Merge commit '853bf98ca1e8a59e3e717538fae88e2b2c7ee8dd' into release #36

Merge commit '853bf98ca1e8a59e3e717538fae88e2b2c7ee8dd' into release

Merge commit '853bf98ca1e8a59e3e717538fae88e2b2c7ee8dd' into release #36

Workflow file for this run

name: deploy
on:
push:
branches:
- "release"
permissions:
packages: write
jobs:
# run-tests:
# runs-on: ubuntu-latest
# steps:
# - ... when tests added
build-and-push-frontend:
runs-on: ubuntu-latest
# needs:
# - run-tests
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: https://ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./frontend
build-args: |
BACKEND_URL=https://${{ vars.CONTAINER_URL }}/api
push: true
tags: |
ghcr.io/ubclaunchpad/neuron-frontend:latest
ghcr.io/ubclaunchpad/neuron-frontend:${{ github.sha }}
build-and-push-backend:
runs-on: ubuntu-latest
# needs:
# - run-tests
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: https://ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./backend
push: true
build-args: |
PORT=3001
tags: |
ghcr.io/ubclaunchpad/neuron-backend:latest
ghcr.io/ubclaunchpad/neuron-backend:${{ github.sha }}
migrate-rds:
runs-on: ubuntu-latest
env:
DATABASE_URL: mysql://${{ vars.RDS_USERNAME }}:${{ secrets.RDS_PASSWORD }}@${{ vars.RDS_HOSTNAME }}:${{ vars.RDS_PORT }}/${{ vars.RDS_DB }}
DBMATE_MIGRATIONS_DIR: ./database/migrations
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dbmate
run: |
curl -L https://github.com/amacneil/dbmate/releases/latest/download/dbmate-linux-amd64 -o dbmate
chmod +x dbmate
sudo mv dbmate /usr/local/bin/dbmate
- name: Run DB migrations
run: dbmate up --strict
deploy:
runs-on: ubuntu-latest
needs:
- build-and-push-frontend
- build-and-push-backend
- migrate-rds
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: create env file
run: |
cat > ./envfile <<EOF
GIT_COMMIT_HASH=${{ github.sha }}
CONTAINER_URL=${{ vars.CONTAINER_URL }}
RDS_HOSTNAME=${{ vars.RDS_HOSTNAME }}
RDS_USERNAME=${{ vars.RDS_USERNAME }}
RDS_PORT=${{ vars.RDS_PORT }}
RDS_DB=${{ vars.RDS_DB }}
GMAIL_ID=${{ vars.GMAIL_ID }}
EOF
- name: Docker Stack Deploy
uses: cssnr/stack-deploy-action@v1
with:
name: neuron
file: ./deploy/docker-stack.yml
host: ${{ vars.CONTAINER_URL }}
user: deploy
ssh_key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
env_file: ./envfile