Skip to content

push Dockerfile

push Dockerfile #680

Workflow file for this run

name: Deploy workflow
on: [push]
concurrency:
group: push-${{ github.ref }}
cancel-in-progress: true
jobs:
install:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm i
- run: pnpm lint
- run: pnpm sync
- run: pnpm check
- run: |
wget 'https://github.com/wangfenjin/simple/releases/download/v0.4.0/libsimple-linux-ubuntu-latest.zip'
unzip libsimple-linux-ubuntu-latest.zip
cp libsimple-linux-ubuntu-latest/libsimple.so ./db/
- run: pnpm test
- run: pnpm build
- name: Send Notification
uses: haishanh/actions-telegram-notification@v2
if: ${{ always() }}
with:
notification-token: ${{ secrets.TG_NOTIFICATION_TOKEN }}
job-status: ${{ job.status }}
docker:
needs: install
runs-on: ubuntu-latest
if: >
github.event_name == 'push' &&
(
startsWith(github.event.ref, 'refs/tags/') ||
startsWith(github.event.ref, 'refs/heads/v') ||
github.event.ref == 'refs/heads/main' ||
github.event.ref == 'refs/heads/test'
)
steps:
- uses: actions/checkout@v4
# - name: Cache Docker layers
# uses: actions/cache@v3
# with:
# path: /tmp/.buildx-cache
# key: ${{ runner.os }}-buildx-${{ github.sha }}
# restore-keys: |
# ${{ runner.os }}-buildx-
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: |
haishanh/cherry
# ghcr.io/haishanh/cherry
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set git commit sha
id: revparse
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Builder instance name
run: echo ${{ steps.buildx.outputs.name }}
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Login to r.haishan.me
uses: docker/login-action@v3
with:
registry: r.haishan.me
username: ${{ github.actor }}
password: ${{ secrets.R_HAISHAN_ME_PASSWORD }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker_meta.outputs.tags }},ghcr.io/${{ steps.docker_meta.outputs.tags }}
build-args: |
COMMIT_SHA=${{ env.sha_short }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- run: |
printf '**Docker images**' >> $GITHUB_STEP_SUMMARY
printf "\n" >> $GITHUB_STEP_SUMMARY
printf '```' >> $GITHUB_STEP_SUMMARY
printf "\n" >> $GITHUB_STEP_SUMMARY
printf "$TAGS" >> $GITHUB_STEP_SUMMARY
printf "\n" >> $GITHUB_STEP_SUMMARY
printf '```' >> $GITHUB_STEP_SUMMARY
printf "\n" >> $GITHUB_STEP_SUMMARY
env:
TAGS: ${{ steps.docker_meta.outputs.tags }}
- name: Send Notification
uses: haishanh/actions-telegram-notification@v2
if: ${{ always() }}
with:
notification-token: ${{ secrets.TG_NOTIFICATION_TOKEN }}
job-status: ${{ job.status }}