Skip to content

Commit

Permalink
ci: build and push docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangt2333 committed Apr 20, 2024
1 parent 7db6ac0 commit c0e2c1e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 10 deletions.
56 changes: 46 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ on:
- master
workflow_dispatch: # add manual button

permissions:
contents: write
packages: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

steps:
- uses: actions/checkout@v4

Expand All @@ -24,9 +26,43 @@ jobs:
- run: npm install
- run: npm run build

- name: Deploy
uses: peaceiris/actions-gh-pages@v4
# upload to artifact
- uses: actions/upload-artifact@v4
with:
name: "web"
path: |
dist/*
# build Docker Image
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
latest
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: release
publish_dir: dist
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM scratch

COPY ./dist/ /app/

0 comments on commit c0e2c1e

Please sign in to comment.