docker #76
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: docker | |
# 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: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- scripts/** | |
- .github/workflows/dockerfile.yaml | |
env: | |
TZ: Asia/Shanghai | |
jobs: | |
build: | |
strategy: | |
matrix: | |
include: | |
- name: Jenkins docker image | |
dockerfilePath: dockerfile/jenkins-base/Dockerfile | |
prebuildPath: dockerfile/jenkins-base/prebuild.sh | |
imageName: harbor.maa-org.net/maa/jenkins-base | |
- name: Minio cronjob docker image | |
dockerfilePath: dockerfile/minio-cronjob/Dockerfile | |
imageName: harbor.maa-org.net/maa/minio-cronjob | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout MaaAssistantArknights/containers | |
uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
repository: MaaAssistantArknights/containers | |
path: MaaContainers | |
- name: Checkout MaaAssistantArknights/MaaRelease | |
uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
repository: MaaAssistantArknights/MaaRelease | |
path: MaaRelease | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
check-latest: true | |
cache: npm | |
cache-dependency-path: MaaRelease/scripts/package-lock.json | |
- name: Installing the dependencies | |
uses: AnnAngela/cached_node-modules@v2 | |
with: | |
command: npm run ciInCI | |
cwd: MaaRelease/scripts | |
- name: Run prebuild.sh | |
if: matrix.prebuildPath != '' | |
run: sh MaaContainers/${{ matrix.prebuildPath }} | |
- name: Setup Docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log into registry | |
uses: docker/login-action@v3 | |
with: | |
registry: harbor.maa-org.net | |
username: ${{ secrets.MAA_HARBOR_ROBOT_USERNAME }} | |
password: ${{ secrets.MAA_HARBOR_ROBOT_PASSWORD }} # 每 30 天更新一次 | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ matrix.imageName }} | |
tags: | | |
type=raw,value=latest | |
type=sha,prefix={{date 'Y-MM-DDTHH-mm-ss[Z]'}}_ | |
- name: Build and push Docker image | |
id: build-and-push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: MaaContainers/${{ matrix.dockerfilePath }} | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
provenance: mode=max | |
sbom: true |