Skip to content
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

Feature workflow 3 #11

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: GitHub Actions Workflow

on:
workflow_dispatch:
push:
branches:
- 'master, feature-workflow'

jobs:

build:
runs-on: ubuntu-20.04

steps:
# run tests, run build, create a docker image based on dockerfile
- name: Check out repository code
uses: actions/checkout@v3
- name: install node packages
uses: actions/setup-node@v3
with:
node-version: '17.9.0'
cache: 'npm'
- run: npm install
# included tests of this angular-app dont work, so we need skip tests to testing workflow
# - run: npm test
- run: npm run build
- name: Build the Docker image
run: docker build -t ghcr.io/shurenbergen/angular-starter:${{ github.run_number }} .

# store created docker image in the github packages
- name: Login to GitHub Packages
run: echo ${{ secrets.AUTH_TOKEN }} | docker login ghcr.io -u Shurenbergen --password-stdin
- name: Push the Docker image to GitHub Packages
run: docker push ghcr.io/shurenbergen/angular-starter:${{ github.run_number }}

# send notifications to email
- name: Send notification
if: always()
uses: dawidd6/action-send-mail@v2
with:
server_address: smtp.gmail.com
server_port: 587
username: ${{ secrets.EMAIL_USERNAME }}
password: ${{ secrets.EMAIL_PASSWORD }}
subject: ${{ github.job }} job of ${{ github.repository }} has ${{ job.status }}
# email body as text
body: ${{ github.job }} job in workflow ${{ github.workflow }} of ${{ github.repository }} has ${{ job.status }}
# send email to
to: Sham-aleksandr@yandex.ru
# from email name
from: Sham Aleksandr
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#STAGE_BUILD
FROM node:17-alpine as build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
COPY . /app
RUN npm run build

#STAGE_SERVER
FROM nginx:1.21.6-alpine as server
LABEL maintainer="Aleksandr Sham"
LABEL version="1.0"
COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=build /app/dist/angular-starter /usr/share/nginx/html
# add permissions for nginx user
RUN chown -R nginx:nginx /var/cache/nginx && \
chown -R nginx:nginx /var/log/nginx && \
chown -R nginx:nginx /etc/nginx/conf.d && \
chown -R nginx:nginx /etc/nginx/nginx.conf && \
touch /var/run/nginx.pid && \
chown -R nginx:nginx /var/run/nginx.pid
# switch to non-root user
USER nginx
13 changes: 13 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
events{}
http {
include /etc/nginx/mime.types;
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
}