👷 CI: auto build (#81)

为 Alpine 容器清空 pip cache 并自动构建 alpine 容器
This commit is contained in:
wy580477 2024-06-30 21:58:59 +08:00 committed by GitHub
parent 58a204d36c
commit b0a807b82c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 79 additions and 0 deletions

78
.github/workflows/Docker-alpine.yml vendored Normal file
View File

@ -0,0 +1,78 @@
name: Docker_alpine
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
push:
branches: [ development ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Pull Repo
run: |
git clone --branch $GITHUB_REF_NAME --depth 1 https://github.com/${GITHUB_REPOSITORY} repo
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=edge,suffix=-alpine,branch=development
type=sha,suffix=-alpine
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./repo
file: ./repo/Dockerfile.alpine
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@ -12,6 +12,7 @@ RUN apk add --no-cache git bash imagemagick libmagic curl tzdata neofetch libzba
&& apk add --no-cache --update --virtual .build-deps gcc python3-dev musl-dev linux-headers \ && apk add --no-cache --update --virtual .build-deps gcc python3-dev musl-dev linux-headers \
&& git config --global pull.ff only \ && git config --global pull.ff only \
&& pip install -r requirements.txt \ && pip install -r requirements.txt \
&& pip cache purge \
&& apk del .build-deps && apk del .build-deps
ENTRYPOINT ["tini","--","bash","utils/docker-config.sh"] ENTRYPOINT ["tini","--","bash","utils/docker-config.sh"]