Skip to content

Commit

Permalink
ci: ✨ add docker
Browse files Browse the repository at this point in the history
  • Loading branch information
12ain committed May 17, 2023
1 parent 29963b0 commit 163b8b2
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 9 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
on:
push:
branches:
- vue-press

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
COMMENT_SECRET: ${{ secrets.COMMENT_SECRET }}
COMMENT_APPID: ${{ secrets.COMMENT_APPID }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 16

- name: Build
run: |
yarn
yarn build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver: docker

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=true
tags: |
type=schedule
type=ref,event=tag
type=sha,prefix=,format=long,enable=true,priority=100
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
21 changes: 12 additions & 9 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2

- uses: actions/setup-node@v3
with:
node-version: 16

- name: Install
run: npm i

- name: Build
run: npm run build
- name: Install And Build
run: |
yarn
yarn build
- name: Add Domain
run: cd public && echo 'blog.abplan.top' > CNAME

- name: Install SSH Client
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DEPLOY_KEY }}
# - name: Install SSH Client
# uses: webfactory/[email protected]
# with:
# ssh-private-key: ${{ secrets.DEPLOY_KEY }}

- name: Deploy
uses: JamesIves/github-pages-deploy-action@releases/v3
Expand Down
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM nginx:stable-alpine

RUN rm -rf /usr/share/nginx/html/*

COPY conf/nginx.conf /etc/nginx/nginx.conf
COPY ./public /app

EXPOSE 80

ENTRYPOINT ["nginx", "-g", "daemon off;"]
34 changes: 34 additions & 0 deletions conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
user nginx;

worker_processes 1;
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"';
sendfile on;
keepalive_timeout 65;

server {
listen 80;
server_name _ default_server;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log error;
# Hide nginx version information.
server_tokens off;

location / {
root /app;
index index.html;
add_header Cache-Control "no-store";
try_files $uri $uri/index.html /index.html;
# proxy_set_header Host $host;
}
}
}

1 comment on commit 163b8b2

@vercel
Copy link

@vercel vercel bot commented on 163b8b2 May 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.