Components for custom mdx. #99
Workflow file for this run
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: Release Dev Docker image to Linode | |
on: | |
push: | |
branches-ignore: | |
- 'master' | |
env: | |
IMAGE_NAME_SERVER: ${{ secrets.DOCKER_USERNAME }}/derecksnotes-server | |
IMAGE_NAME_CLIENT: ${{ secrets.DOCKER_USERNAME }}/derecksnotes-client | |
CONTAINER_NAME_SERVER: linode_derecksnotes-server | |
CONTAINER_NAME_CLIENT: linode_derecksnotes-client | |
jobs: | |
push_to_registry_server: | |
name: Push Docker server image to Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to Docker Hub | |
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Create .env file | |
run: | | |
echo BUILD_ENV=DEV > ./server/.env | |
echo API_URL=https://dev.derecksnotes.com >> ./server/.env | |
echo EXPRESS_PORT=3000 >> ./server/.env | |
echo SESSION_SECRET=${{ secrets.SESSION_SECRET }} >> ./server/.env | |
echo MONGO_PASSWORD=${{ secrets.MONGO_PASSWORD }} >> ./server/.env | |
- name: Build and push server image | |
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 | |
with: | |
context: ./server | |
file: ./server/Dockerfile | |
push: true | |
tags: ${{ env.IMAGE_NAME_SERVER }}:latest_dev | |
push_to_registry_client: | |
name: Push Docker client image to Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to Docker Hub | |
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Create .env file | |
run: | | |
echo NEXT_PUBLIC_BUILD_ENV=DEV > ./client/.env | |
echo NEXT_PUBLIC_APP_URL=https://dev.derecksnotes.com/ >> ./client/.env | |
- name: Build and push client image | |
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 | |
with: | |
context: ./ | |
file: ./client/Dockerfile | |
push: true | |
tags: ${{ env.IMAGE_NAME_CLIENT }}:latest_dev | |
build-args: | | |
NEXT_PUBLIC_BUILD_ENV=DEV | |
NEXT_PUBLIC_APP_URL=https://dev.derecksnotes.com/ | |
deploy_to_linode: | |
name: Deploy docker-compose.yml to Linode | |
needs: [push_to_registry_server, push_to_registry_client] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Copy docker-compose.yml to remote server | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.REMOTE_HOST }} | |
username: ${{ secrets.REMOTE_USERNAME }} | |
password: ${{ secrets.REMOTE_PASSWORD }} | |
port: ${{ secrets.REMOTE_PORT }} | |
source: './docker-compose.yml' | |
target: '/root/docker-compose-derecksnotes/' | |
- name: Deploy to remote server | |
uses: appleboy/[email protected] | |
env: | |
IMAGE_NAME_SERVER: ${{ secrets.DOCKER_USERNAME }}/derecksnotes-server:latest_dev | |
IMAGE_NAME_CLIENT: ${{ secrets.DOCKER_USERNAME }}/derecksnotes-client:latest_dev | |
CONTAINER_NAME_SERVER: dev_linode_derecksnotes-server | |
CONTAINER_NAME_CLIENT: dev_linode_derecksnotes-client | |
with: | |
host: ${{ secrets.REMOTE_HOST }} | |
username: ${{ secrets.REMOTE_USERNAME }} | |
password: ${{ secrets.REMOTE_PASSWORD }} | |
port: ${{ secrets.REMOTE_PORT }} | |
envs: IMAGE_NAME_SERVER,IMAGE_NAME_CLIENT,CONTAINER_NAME_SERVER,CONTAINER_NAME_CLIENT | |
script: | | |
cd /root/docker-compose-derecksnotes/ | |
docker pull ${{ env.IMAGE_NAME_SERVER }} | |
docker pull ${{ env.IMAGE_NAME_CLIENT }} | |
docker container prune -f | |
docker image prune -f | |
docker rm -f ${{ env.CONTAINER_NAME_SERVER }} | |
docker rm -f ${{ env.CONTAINER_NAME_CLIENT }} | |
docker compose down | |
docker compose up -d |