feat (backend): confirm email #33
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: Build and Push & Deploy Docker Image of backend service | |
on: | |
push: | |
branches: | |
- task/monorepo | |
paths: | |
- apps/backend/package.json | |
jobs: | |
push_to_registry: | |
name: Push Docker image to Docker Hub & Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: check out the repo | |
uses: actions/checkout@v3 | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20" | |
- name: Extract version from package.json | |
id: get_version | |
run: | | |
VERSION=$(node -p "require('./apps/backend/package.json').version") | |
echo "version=${VERSION}" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Install Docker Compose | |
run: | | |
mkdir -p ~/.docker/cli-plugins/ | |
curl -SL https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose | |
chmod +x ~/.docker/cli-plugins/docker-compose | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{secrets.DOCKERHUB_USERNAME}} | |
password: ${{secrets.DOCKERHUB_TOKEN}} | |
- name: Create .env file from GitHub secret | |
run: | | |
echo "${{ secrets.BACKEND_ENVS }}" > ./apps/backend/.env | |
- name: Determine Docker tag | |
id: docker_tag | |
run: | | |
SHORT_SHA=${GITHUB_SHA::7} #ignore short sha for now | |
TAG="${{ env.version }}" | |
echo "tag=${TAG}" >> $GITHUB_ENV | |
- name: Tag Docker image | |
run: | | |
IMAGE_NAME=${{secrets.DOCKERHUB_USERNAME}}/${{secrets.DOCKERHUB_REPO_NAME}} | |
TAG=${{ env.tag }} | |
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV | |
echo "IMAGE_TAG=$TAG" >> $GITHUB_ENV | |
- name: Docker Compose Build & Push | |
env: | |
IMAGE_NAME: ${{ env.IMAGE_NAME }} | |
IMAGE_TAG: ${{env.IMAGE_TAG}} | |
run: | | |
REMOTE_IMAGE_NAME=${IMAGE_NAME}:${IMAGE_TAG} docker compose -f docker-compose.yml build backend | |
REMOTE_IMAGE_NAME=${IMAGE_NAME}:latest docker compose -f docker-compose.yml build backend | |
REMOTE_IMAGE_NAME=${IMAGE_NAME}:${IMAGE_TAG} docker compose -f docker-compose.yml push backend | |
REMOTE_IMAGE_NAME=${IMAGE_NAME}:latest docker compose -f docker-compose.yml push backend | |
- name: Trigger Render deploy | |
env: | |
DEPLOY_URL: ${{secrets.RENDER_DEPLOY_HOOK_URL}} | |
run: | | |
curl "${DEPLOY_URL}" | |
- name: Notify if push fails | |
if: failure() | |
run: echo "Docker Compose push failed" | tee /dev/stderr |