-
Notifications
You must be signed in to change notification settings - Fork 20
66 lines (57 loc) · 2.08 KB
/
pipeline.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# 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
strategy:
matrix:
node-version: [18.x]
steps:
# Checkout the code from the GitHub repository
- name: Checkout code
uses: actions/checkout@v4
# 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@v3
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}}