Docker-caching-and-better-slack-notifications (#102)
* test docker caching and slack * try this * this _might_ do it * cleanup * just realized this is running on self-hosted, so github cache doesn't make sense * fix logging noise * cache npm modules during test * fiskerBot and icon * quotes (just in case)
This commit is contained in:
53
.github/workflows/deploy.yml
vendored
53
.github/workflows/deploy.yml
vendored
@@ -3,23 +3,24 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- develop
|
- develop
|
||||||
- main
|
- main
|
||||||
- 'release/**'
|
- "release/**"
|
||||||
- 'hotfix/**'
|
- "hotfix/**"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy
|
name: Deploy
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
env:
|
env:
|
||||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||||
|
SLACK_CHANNEL: "#cloud-builds"
|
||||||
|
SLACK_FOOTER: "Powered by :fisker:"
|
||||||
|
SLACK_USERNAME: fiskerBot
|
||||||
|
SLACK_ICON: "https://github.com/Fisker-Inc.png?size=32"
|
||||||
TAG: ${{ github.sha }}
|
TAG: ${{ github.sha }}
|
||||||
PROJECT: ota-admin-portal
|
PROJECT: ota-admin-portal
|
||||||
steps:
|
steps:
|
||||||
- name: Slack Notify
|
- name: Slack Notification
|
||||||
uses: act10ns/slack@master
|
uses: rtCamp/action-slack-notify@v2
|
||||||
with:
|
|
||||||
channel: "#cloud-builds"
|
|
||||||
status: starting
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Configure AWS Credentials
|
- name: Configure AWS Credentials
|
||||||
@@ -46,13 +47,17 @@ jobs:
|
|||||||
ENVIRONMENT=dev;;
|
ENVIRONMENT=dev;;
|
||||||
esac
|
esac
|
||||||
echo "ENVIRONMENT=${ENVIRONMENT}" >> $GITHUB_ENV
|
echo "ENVIRONMENT=${ENVIRONMENT}" >> $GITHUB_ENV
|
||||||
- name: Build, tag, and push image to Amazon ECR
|
- name: Set up Docker Buildx
|
||||||
id: build-tag-push-image
|
uses: docker/setup-buildx-action@v1
|
||||||
env:
|
- name: Build and push
|
||||||
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
uses: docker/build-push-action@v2
|
||||||
run: |
|
with:
|
||||||
docker build --build-arg ENVIRONMENT=$ENVIRONMENT -t $REGISTRY/$PROJECT:$TAG-$ENVIRONMENT .
|
context: .
|
||||||
docker push $REGISTRY/$PROJECT:$TAG-$ENVIRONMENT
|
build-args: ENVIRONMENT=${{ env.ENVIRONMENT }}
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.login-ecr.outputs.registry }}/${{ env.PROJECT }}:${{ env.TAG}}-${{ env.ENVIRONMENT }}
|
||||||
|
cache-from: type=registry,ref=${{ steps.login-ecr.outputs.registry }}/${{ env.PROJECT }}:${{ env.TAG}}-${{ env.ENVIRONMENT }}
|
||||||
|
cache-to: type=inline
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
id: deploy
|
id: deploy
|
||||||
env:
|
env:
|
||||||
@@ -64,9 +69,15 @@ jobs:
|
|||||||
--set image.name=$PROJECT \
|
--set image.name=$PROJECT \
|
||||||
--set image.tag=$TAG-$ENVIRONMENT \
|
--set image.tag=$TAG-$ENVIRONMENT \
|
||||||
--wait -i -f k8s/values-$ENVIRONMENT.yaml $PROJECT k8s/
|
--wait -i -f k8s/values-$ENVIRONMENT.yaml $PROJECT k8s/
|
||||||
- uses: act10ns/slack@master
|
- name: Notify if success
|
||||||
with:
|
uses: rtCamp/action-slack-notify@v2
|
||||||
channel: "#cloud-builds"
|
env:
|
||||||
status: ${{ job.status }}
|
MSG_MINIMAL: true
|
||||||
message: Successfully deployed to ${{ env.ENVIRONMENT }}!
|
SLACK_MESSAGE: Successfully deployed to ${{ env.ENVIRONMENT }}!
|
||||||
if: always()
|
if: ${{ success() }}
|
||||||
|
- name: Notify if failure
|
||||||
|
uses: rtCamp/action-slack-notify@v2
|
||||||
|
env:
|
||||||
|
SLACK_COLOR: ${{ job.status }}
|
||||||
|
SLACK_MESSAGE: Job failed!
|
||||||
|
if: ${{ failure() }}
|
||||||
|
|||||||
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
@@ -4,19 +4,15 @@ on: [pull_request]
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
node-version: [14.x]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: "14"
|
||||||
|
cache: "npm"
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm run build --if-present
|
- run: npm run build --if-present
|
||||||
- run: npm test
|
- run: npm test
|
||||||
|
|||||||
@@ -10,4 +10,5 @@ RUN npm run build:${ENVIRONMENT}
|
|||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
COPY --from=builder build /usr/share/nginx/html
|
COPY --from=builder build /usr/share/nginx/html
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
COPY nginx.conf /etc/nginx/nginx.conf
|
||||||
|
ENV NGINX_ENTRYPOINT_QUIET_LOGS=true
|
||||||
30
nginx.conf
30
nginx.conf
@@ -1,3 +1,32 @@
|
|||||||
|
user nginx;
|
||||||
|
worker_processes auto;
|
||||||
|
|
||||||
|
error_log /var/log/nginx/error.log warn;
|
||||||
|
pid /var/run/nginx.pid;
|
||||||
|
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
http {
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||||
|
'$status $body_bytes_sent "$http_referer" '
|
||||||
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||||
|
|
||||||
|
access_log /var/log/nginx/access.log main;
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
#tcp_nopush on;
|
||||||
|
|
||||||
|
keepalive_timeout 65;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
@@ -9,3 +38,4 @@ server {
|
|||||||
try_files $uri /index.html;
|
try_files $uri /index.html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user