Skip to content

[promote-production]: May 4, 10:19PM (#34) #1

[promote-production]: May 4, 10:19PM (#34)

[promote-production]: May 4, 10:19PM (#34) #1

Workflow file for this run

# The name of the workflow.
name: Build and Deploy
# Run the workflow when code is pushed to the main branch
on:
push:
branches:
- main
# Set environment variables
env:
MONGODB_URL: ${{ secrets.MONGODB_URL }}
# This is the workflow that is being run.
jobs:
build-and-deploy:
# This is telling GitHub to run the workflow on the latest version of Ubuntu.
runs-on: ubuntu-latest
steps:
# Checkout the code from the GitHub repository
- name: Checkout code
uses: actions/checkout@v2
# Install dependencies and run tests for the client application
- name: Install Client
working-directory: ./client
run: |
npm install
# Install dependencies, export environment variables to be used by application and run tests for the server application
- name: Install Server
working-directory: ./server
run: |
npm install
export MONGODB_URL=$MONGODB_URL
# Build a Docker image for the client application
- name: Build Client Docker Image
working-directory: ./client
# Build image with tag drbarzaga/job-portal:client
run: |
docker build -t drbarzaga/job-portal:client-${{github.run_number}} .
# Build a Docker image for the server application
- name: Build Server Docker Image
working-directory:
./server
# Build image with tag drbarzaga/job-portal:server
run: |
docker build -t drbarzaga/job-portal:server-${{github.run_number}} .
# Login to Docker Hub using credentials from repository secrets
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Push the Docker images to Docker Hub
- name: Push Docker Images to Docker Hub
run: |
docker push drbarzaga/job-portal:client-${{github.run_number}}
docker push drbarzaga/job-portal:server-${{github.run_number}}