Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
361775d
Create main.yml
LePaVuki Oct 16, 2024
323beab
Update main.yml
LePaVuki Oct 16, 2024
59bcbf7
Update main.yml
LePaVuki Oct 16, 2024
f08c801
Update main.yml
LePaVuki Oct 16, 2024
5d0c0fe
Update main.yml
LePaVuki Oct 16, 2024
fa82b4f
changed readme
LePaVuki Oct 16, 2024
e9fca65
Update main.yml
LePaVuki Oct 16, 2024
bc059b5
Made actions run tests for node locally
LePaVuki Oct 17, 2024
4c4144e
changed readme back
LePaVuki Oct 17, 2024
9c8b8f4
renamed workflow
LePaVuki Oct 17, 2024
43bb14f
Added ng build
LePaVuki Oct 17, 2024
fa5e25f
Added docker image building to ci
LePaVuki Oct 17, 2024
163bf99
added loging to Container registry and pushing docker image
LePaVuki Oct 17, 2024
8c9acdb
changed logging username
LePaVuki Oct 17, 2024
13fc9cc
added tags to the building step
LePaVuki Oct 17, 2024
601c2b1
Changed labeling and authorisation on push
LePaVuki Oct 17, 2024
7b031ff
renamed tasks within the job to test successful workflow run and emai…
LePaVuki Oct 17, 2024
fcd442e
Changed compose.yaml to pull the image from GitHub
LePaVuki Oct 17, 2024
ffef346
changed user loggin in the Dockerfile and made compose pull from the …
LePaVuki Oct 17, 2024
c93d16c
fixed user creation in dockerfile
LePaVuki Oct 17, 2024
f62b8e0
chanfed directory of nginx.conf to copy to inside the container
LePaVuki Oct 17, 2024
1eb4c6f
version with 2 .conf files being copied both to ./angular and /etc/ng…
LePaVuki Oct 17, 2024
341d580
disabled user creation in dockerfile
LePaVuki Oct 17, 2024
f2db672
changed username in nginx.conf to Nginx and restored user creation in…
LePaVuki Oct 17, 2024
209b280
changed to unpriveleged version of Nginx in Dockerfile
LePaVuki Oct 17, 2024
8218d32
Fixed the name of the Nginx image in dockerfile
LePaVuki Oct 17, 2024
9fc6041
restored the username in nginx.conf to www-data, changed which nginx.…
LePaVuki Oct 18, 2024
bef7cb1
changed nginx image to pull a regular one
LePaVuki Oct 18, 2024
881ffca
Changed Dockerfile and nginx.conf
LePaVuki Oct 18, 2024
ebee6bb
Changed Dockerfile to copy angular-starter into Nginx folder at var/w…
LePaVuki Oct 18, 2024
df201b3
chenged nginx.conf to only listen to 80 port (no ipv6)
LePaVuki Oct 18, 2024
4c28c20
Changed paths in Dockerfile to relative
LePaVuki Oct 18, 2024
130a4d0
Changed nginx.conf
LePaVuki Oct 18, 2024
a393045
Changed port forwarding in docker compose and root in nginx.conf
LePaVuki Oct 18, 2024
3d14619
Final commit before pull
LePaVuki Oct 19, 2024
7ba0a76
Got rid of staging in the dockerfile
LePaVuki Oct 22, 2024
cefbaaf
Renamed compose.yaml -> docker-compose.yaml
LePaVuki Oct 22, 2024
2a786c3
Changed steps names to lowercase
LePaVuki Oct 22, 2024
6e79b9b
Changed main nginx.conf file
LePaVuki Oct 22, 2024
25f479e
Removed unnecesary trigger to run action on pull-request
LePaVuki Oct 22, 2024
46d0347
Changed working directory to angular for tests
LePaVuki Oct 22, 2024
f425c5f
Got rid of permissions, swapped to native npm build
LePaVuki Oct 22, 2024
cbd8cc7
Changed workflow to use github.token instead of secrets.GITHUB_TOKEN
LePaVuki Oct 22, 2024
3c168cb
Got rid of the browser setup in the workflow
LePaVuki Oct 22, 2024
167f882
Added xvfb action to the Karma Tests step
LePaVuki Oct 22, 2024
5aaa75e
Fixed xvfb action in ci.yml
LePaVuki Oct 22, 2024
a37db11
Minor renames, setup Node step
LePaVuki Oct 25, 2024
9e78afe
Changed Karma tests run
LePaVuki Oct 25, 2024
b904772
Changed docker-compose to pull correct image name
LePaVuki Oct 25, 2024
5321b0e
Simplified nginx.conf
LePaVuki Oct 25, 2024
60017c5
Adjusted nginx.conf
LePaVuki Oct 25, 2024
eab9449
Specified node version in package.json
LePaVuki Oct 25, 2024
0a6e9cc
Added email notification and time tracking
LePaVuki Oct 25, 2024
048b11a
Reverted docker-compose from local building to web image pulling
LePaVuki Oct 25, 2024
846be52
Specified CMD in dockerfile to run Nginx
LePaVuki Oct 25, 2024
80a5895
Added mime types to include in the Nginx.conf
LePaVuki Oct 25, 2024
9eed310
Resructurised workflows
LePaVuki Oct 28, 2024
e345320
Separated most of the jobs to separate workflows
LePaVuki Oct 28, 2024
16aaf8f
Changed success display of jobs in the email
LePaVuki Oct 28, 2024
8d946b6
got rid of separate time count
LePaVuki Oct 28, 2024
8dddc17
Simplified workflow to 2 separate files
LePaVuki Oct 28, 2024
c7f5060
changed nginx.conf to incorrect for workflow test
LePaVuki Oct 28, 2024
9a26014
Update ci.yml
LePaVuki Oct 28, 2024
55ad481
fixed nginx.conf and build-angular
LePaVuki Oct 28, 2024
6703973
broke Build Angular step to test workflow
LePaVuki Oct 28, 2024
be14081
Changed tagging of the docker image
LePaVuki Oct 28, 2024
0230ed1
Update readability of build-angular.yml
LePaVuki Oct 28, 2024
945cdfa
Renamed workflow to fit with the code
LePaVuki Oct 30, 2024
b6b3b47
Rename of the workflow
LePaVuki Oct 30, 2024
4475522
Condensed code
LePaVuki Oct 30, 2024
876401d
Added the workflows description
LePaVuki Oct 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions .github/workflows/build-angular.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# --------------------------------------------------------------
# GitHub Actions Workflow: build-angular
#
# Description:
# This workflow automates the process of building, testing and packaging
# of the Angular app project.
# It consists of a single job with multiple steps, that insure
# succesful building and testing of the Angular app. After succesful
# building of the project, docker image is being created and uploaded
# to specified registry. After finishing the workflow, an email
# notification is being sent to a specified email address.
# Email contains total time of the workflow execution and it's status
#
# Triggers:
# - on:
# - workflow_call: Executes on a call from another workflow
#
# Jobs:
# - build-Angular: builds, tests and packages an image of
# an Angular app, served by Nginx. Sends an email notification
# at the end of the workflow
#
# Notes:
# - Requires the following secrets to be passed from a calling workflow:
# email_username: username for email authorisation
# email_password: password for email authorisation
# mail_receiver: email address of the notification receiver
# mail_sender: displayed name of the notification sender
#
# Expected Outcome:
# - Successful execution of this workflow should result in a
# new image being published to the specified registry and email notification
# being sent to an address from GitHub secrets.
#
# --------------------------------------------------------------

name: build-angular

on:
workflow_call:
inputs:
mail_address:
description: "Mail server address"
default: "smtp.gmail.com"
required: true
type: string
mail_port:
description: "Mail server port"
default: 465
required: true
type: number
image_name:
description: "Name of the uploaded image"
required: true
type: string
registry:
description: "Package upload registry"
required: true
type: string
secrets:
email_username:
description: "Email username"
required: true
email_password:
description: "Email password"
required: true
mail_receiver:
description: "Email of the receiver"
required: true
mail_sender:
description: "The notification sender displayed name"
required: true

jobs:

build-image:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./angular

steps:

- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: angular/package.json

- name: Install Angular
run: npm ci

- name: Run Karma Tests
id: run-tests
run: npm run coverage -- --browsers=ChromeHeadless

- name: Build Angular
run: npm run build

- name: Login to the Container registry
uses: docker/[email protected]
with:
registry: ${{ inputs.registry }}
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ inputs.registry }}/${{ inputs.image_name }}
flavor: |
latest=true
tags: |
type=ref,event=branch
type=ref,event=pr

- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Get steps execution time
if: always()
id: duration
uses: RockyIsHere/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Deliver email
if: always()
uses: dawidd6/action-send-mail@v3
with:
server_address: ${{ inputs.mail_address }}
server_port: ${{ inputs.mail_port }}
username: ${{secrets.email_username}}
password: ${{secrets.email_password}}
subject: GH Action ${{ github.repository }} ${{ github.workflow }} ${{ job.status }}
to: ${{ secrets.mail_receiver }}
from: ${{ secrets.mail_sender }}
convert_markdown: true
html_body: |
Workflow on ${{ github.repository }}: ${{ job.status }}
---
Execution time: ${{ steps.duration.outputs.duration }}
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# --------------------------------------------------------------
# GitHub Actions Workflow: build-angular
#
# Description:
# This workflow automates the process of building, testing and packaging
# of the Angular app project.
# It consists of a single job calling build-angular modular workflow
#
# Triggers:
# - on:
# - push: Executes on a push to master.
# - pull_request: Executes on a pull request to master.
#
# Jobs:
# - build-Angular: Runs a callable workflow "build-angular", which
# builds, tests and packages an image of an Angular app, served by Nginx
# At the end of the workflow, calculates total time of execution and
# sends an email notification with the outcome and total time.
#
# Notes:
# - Requires the following secrets to be configured in the GitHub
# repository:
# email_username: username for email authorisation
# email_password: password for email authorisation
# mail_receiver: email address of the notification receiver
# mail_sender: displayed name of the notification sender
# - Requires presence of the build-angular.yml workflow in
# the GitHub workflows folder
#
# Expected Outcome:
# - Successful execution of this workflow should result in [state
# the outcome, e.g., "a new Docker image published to Docker Hub"
# or "a deployed app on production servers"].
#
# --------------------------------------------------------------

name: ci

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:

build-Angular:
uses: ./.github/workflows/build-angular.yml

with:
image_name: ${{ github.repository }}
registry: "ghcr.io"
mail_address: "smtp.gmail.com"
mail_port: 465

secrets:
email_username: ${{secrets.email_username}}
email_password: ${{secrets.email_password}}
mail_receiver: ${{ secrets.mail_receiver }}
mail_sender: ${{ secrets.mail_sender }}
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# nginxinc/nginx-unprivileged:alpine3.20-perl
FROM nginxinc/nginx-unprivileged@sha256:ccbef5da6a3ae2ffab0a440944c817adead587970772b5b911c54ffdf5832e27

COPY ./nginx.conf /etc/nginx/nginx.conf
COPY ./angular/dist/angular-starter /var/www/html

USER nginx

CMD "nginx"
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,3 @@ Here is a step by step Tutorial : https://www.ganatan.com/tutorials/getting-sta
## [Tutoriels React en français](#french-tutorials)
- Installation - https://www.ganatan.com/tutorials/demarrer-avec-react
- Tutoriels Etape par étape - https://www.ganatan.com/tutorials

3 changes: 3 additions & 0 deletions angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "angular-starter",
"version": "18.2.1",
"engines": {
"node": ">=18.19.1"
},
"scripts": {
"ng": "ng",
"dev": "ng serve --port 4200",
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:

nginx-angular:
container_name: nginx-angular
image: ghcr.io/lepavuki/angular-react-devops-case:pr-3
ports:
- 8080:8080
24 changes: 24 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
daemon off;
pid /tmp/nginx.pid;

events {

worker_connections 2000;

}

http {
include mime.types;

server {
listen 8080;

location / {

root /var/www/html/browser;
index index.html;

}

}
}
Loading
Loading