Push docker image to ghcr

This commit is contained in:
Haishan 2022-03-06 17:32:23 +08:00
parent 8b2e4b6609
commit 6e6076242d
3 changed files with 21 additions and 11 deletions

View file

@ -5,10 +5,10 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
matrix: matrix:
node-version: [14.x] node-version: [16.x]
steps: steps:
- uses: actions/checkout@v2.4.0 - uses: actions/checkout@v3.0.0
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3 uses: actions/setup-node@v3
@ -88,7 +88,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
if: github.event_name == 'push' && (startsWith(github.event.ref, 'refs/tags/') || startsWith(github.event.ref, 'refs/heads/v0.') || github.event.ref == 'refs/heads/master' || github.event.ref == 'refs/heads/test') if: github.event_name == 'push' && (startsWith(github.event.ref, 'refs/tags/') || startsWith(github.event.ref, 'refs/heads/v0.') || github.event.ref == 'refs/heads/master' || github.event.ref == 'refs/heads/test')
steps: steps:
- uses: actions/checkout@v2.4.0 - uses: actions/checkout@v3.0.0
- name: Cache Docker layers - name: Cache Docker layers
uses: actions/cache@v2.1.7 uses: actions/cache@v2.1.7
@ -119,11 +119,18 @@ jobs:
run: echo ${{ steps.buildx.outputs.platforms }} run: echo ${{ steps.buildx.outputs.platforms }}
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v1.10.0 uses: docker/login-action@v1.14.1
with: with:
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }} password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Login to GHCR
uses: docker/login-action@v1.10.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push - name: Build and push
id: docker_build id: docker_build
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
@ -132,7 +139,7 @@ jobs:
file: ./Dockerfile file: ./Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64 platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true push: true
tags: ${{ steps.docker_meta.outputs.tags }} tags: ${{ steps.docker_meta.outputs.tags }},ghcr.io/${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }} labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=gha cache-from: type=gha
cache-to: type=gha cache-to: type=gha

View file

@ -1,11 +1,11 @@
FROM --platform=$BUILDPLATFORM node:alpine AS builder FROM --platform=$BUILDPLATFORM node:alpine AS builder
WORKDIR /app WORKDIR /app
COPY yarn.lock package.json .
RUN yarn config set network-timeout 300000 && yarn
COPY . . COPY . .
# Using yarn to install dependencies in CI will cause network timeout RUN yarn build \
# Refer to https://github.com/date-fns/date-fns/issues/1004
RUN yarn config set network-timeout 300000 \
&& yarn \
&& yarn build \
# remove source maps - people like small image # remove source maps - people like small image
&& rm public/*.map || true && rm public/*.map || true

View file

@ -6,7 +6,10 @@
The site [http://yacd.haishan.me](http://yacd.haishan.me) is served with HTTP not HTTPS is because many browsers block requests to HTTP resources from a HTTPS website. If you think it's not safe, you could just download the [zip of the gh-pages](https://github.com/haishanh/yacd/archive/gh-pages.zip), unzip and open or serve `index.html` directly. The site [http://yacd.haishan.me](http://yacd.haishan.me) is served with HTTP not HTTPS is because many browsers block requests to HTTP resources from a HTTPS website. If you think it's not safe, you could just download the [zip of the gh-pages](https://github.com/haishanh/yacd/archive/gh-pages.zip), unzip and open or serve `index.html` directly.
[Docker image](https://hub.docker.com/r/haishanh/yacd) is also available as `haishanh/yacd`. Docker image
- Docker Hub [`haishanh/yacd`](https://hub.docker.com/r/haishanh/yacd)
- GitHub Container Registry [`ghcr.io/haishanh/yacd`](https://github.com/haishanh/yacd/pkgs/container/yacd)
## Development ## Development