forked from ganatan/angular-react-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
DevOps task formal PR #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LePaVuki
wants to merge
71
commits into
master
Choose a base branch
from
Final-pull
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
361775d
Create main.yml
LePaVuki 323beab
Update main.yml
LePaVuki 59bcbf7
Update main.yml
LePaVuki f08c801
Update main.yml
LePaVuki 5d0c0fe
Update main.yml
LePaVuki fa82b4f
changed readme
LePaVuki e9fca65
Update main.yml
LePaVuki bc059b5
Made actions run tests for node locally
LePaVuki 4c4144e
changed readme back
LePaVuki 9c8b8f4
renamed workflow
LePaVuki 43bb14f
Added ng build
LePaVuki fa5e25f
Added docker image building to ci
LePaVuki 163bf99
added loging to Container registry and pushing docker image
LePaVuki 8c9acdb
changed logging username
LePaVuki 13fc9cc
added tags to the building step
LePaVuki 601c2b1
Changed labeling and authorisation on push
LePaVuki 7b031ff
renamed tasks within the job to test successful workflow run and emai…
LePaVuki fcd442e
Changed compose.yaml to pull the image from GitHub
LePaVuki ffef346
changed user loggin in the Dockerfile and made compose pull from the …
LePaVuki c93d16c
fixed user creation in dockerfile
LePaVuki f62b8e0
chanfed directory of nginx.conf to copy to inside the container
LePaVuki 1eb4c6f
version with 2 .conf files being copied both to ./angular and /etc/ng…
LePaVuki 341d580
disabled user creation in dockerfile
LePaVuki f2db672
changed username in nginx.conf to Nginx and restored user creation in…
LePaVuki 209b280
changed to unpriveleged version of Nginx in Dockerfile
LePaVuki 8218d32
Fixed the name of the Nginx image in dockerfile
LePaVuki 9fc6041
restored the username in nginx.conf to www-data, changed which nginx.…
LePaVuki bef7cb1
changed nginx image to pull a regular one
LePaVuki 881ffca
Changed Dockerfile and nginx.conf
LePaVuki ebee6bb
Changed Dockerfile to copy angular-starter into Nginx folder at var/w…
LePaVuki df201b3
chenged nginx.conf to only listen to 80 port (no ipv6)
LePaVuki 4c28c20
Changed paths in Dockerfile to relative
LePaVuki 130a4d0
Changed nginx.conf
LePaVuki a393045
Changed port forwarding in docker compose and root in nginx.conf
LePaVuki 3d14619
Final commit before pull
LePaVuki 7ba0a76
Got rid of staging in the dockerfile
LePaVuki cefbaaf
Renamed compose.yaml -> docker-compose.yaml
LePaVuki 2a786c3
Changed steps names to lowercase
LePaVuki 6e79b9b
Changed main nginx.conf file
LePaVuki 25f479e
Removed unnecesary trigger to run action on pull-request
LePaVuki 46d0347
Changed working directory to angular for tests
LePaVuki f425c5f
Got rid of permissions, swapped to native npm build
LePaVuki cbd8cc7
Changed workflow to use github.token instead of secrets.GITHUB_TOKEN
LePaVuki 3c168cb
Got rid of the browser setup in the workflow
LePaVuki 167f882
Added xvfb action to the Karma Tests step
LePaVuki 5aaa75e
Fixed xvfb action in ci.yml
LePaVuki a37db11
Minor renames, setup Node step
LePaVuki 9e78afe
Changed Karma tests run
LePaVuki b904772
Changed docker-compose to pull correct image name
LePaVuki 5321b0e
Simplified nginx.conf
LePaVuki 60017c5
Adjusted nginx.conf
LePaVuki eab9449
Specified node version in package.json
LePaVuki 0a6e9cc
Added email notification and time tracking
LePaVuki 048b11a
Reverted docker-compose from local building to web image pulling
LePaVuki 846be52
Specified CMD in dockerfile to run Nginx
LePaVuki 80a5895
Added mime types to include in the Nginx.conf
LePaVuki 9eed310
Resructurised workflows
LePaVuki e345320
Separated most of the jobs to separate workflows
LePaVuki 16aaf8f
Changed success display of jobs in the email
LePaVuki 8d946b6
got rid of separate time count
LePaVuki 8dddc17
Simplified workflow to 2 separate files
LePaVuki c7f5060
changed nginx.conf to incorrect for workflow test
LePaVuki 9a26014
Update ci.yml
LePaVuki 55ad481
fixed nginx.conf and build-angular
LePaVuki 6703973
broke Build Angular step to test workflow
LePaVuki be14081
Changed tagging of the docker image
LePaVuki 0230ed1
Update readability of build-angular.yml
LePaVuki 945cdfa
Renamed workflow to fit with the code
LePaVuki b6b3b47
Rename of the workflow
LePaVuki 4475522
Condensed code
LePaVuki 876401d
Added the workflows description
LePaVuki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| 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 }} |
kseniyashaydurova marked this conversation as resolved.
Show resolved
Hide resolved
LePaVuki marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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
| 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 }} |
This file contains hidden or 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
| 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" |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| 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 | ||
LePaVuki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ports: | ||
| - 8080:8080 | ||
This file contains hidden or 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
| 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; | ||
|
|
||
| } | ||
|
|
||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.