Skip to content

feat(action): main还是去掉arm,本来一分钟就能编译完,加上arm要七分钟不止。 #65

feat(action): main还是去掉arm,本来一分钟就能编译完,加上arm要七分钟不止。

feat(action): main还是去掉arm,本来一分钟就能编译完,加上arm要七分钟不止。 #65

name: Docker
on:
push:
branches: '*'
tags: '*'
paths:
- '.github/**'
- 'src/**'
- '.gitmodules'
- 'lsky-pro'
pull_request:
branches: "main"
paths:
- '.github/**'
- 'src/**'
- '.gitmodules'
- 'lsky-pro'
env:
IMAGE_NAME: ${{ github.actor }}/lsky-pro
LOWERCASE_IMAGE_NAME: ""
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: Checkout code
uses: actions/checkout@v4
- name: Update Submodule
run: git submodule update --init --recursive
- name: Composer Install
uses: php-actions/composer@v6
with:
php_version: "8.1"
working_dir: "lsky-pro"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Convert IMAGE_NAME to lowercase
run: |
IMAGE_NAME=${{ env.IMAGE_NAME }}
echo "LOWERCASE_IMAGE_NAME=${IMAGE_NAME,,}" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
if: startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
file: src/Dockerfile
#platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ env.LOWERCASE_IMAGE_NAME }}:${{ github.ref_name }}
cache-from: type=gha
cache-to: type=gha,mode=max
# 发布tag时推送到dockerhub
- name: Push Docker image to Docker Hub (on tag push)
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v6
with:
context: .
file: src/Dockerfile
#platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.LOWERCASE_IMAGE_NAME }}:latest
${{ env.LOWERCASE_IMAGE_NAME }}:${{ github.ref_name }}
cache-from: type=gha
cache-to: type=gha,mode=max