Docker Image #135
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 Image | |
on: | |
push: | |
branchs: | |
- master | |
schedule: | |
- cron: '0 0 * * 1' | |
env: | |
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_ACCESSTOKEN }} | |
ALIYUN_IMAGE_TOKEN: ${{ secrets.ALIYUN_IMAGE_ACCESSTOKEN }} | |
jobs: | |
build: | |
name: Image ${{ matrix.php-mode }}-${{ matrix.php-version }}-${{ matrix.system }}-${{ matrix.platform }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: | |
- '8.1' | |
- '8.2' | |
- '8.3' | |
php-mode: | |
- fpm | |
- cli | |
system: | |
- alpine | |
- bookworm | |
platform: | |
- linux/amd64 | |
- linux/arm64 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Recognize tag | |
run: | | |
platform=$(echo ${{ matrix.platform }} | sed 's/linux\///g') | |
tag=$platform'-'${{ matrix.php-mode }}-${{ matrix.php-version }}-${{ matrix.system }} | |
echo $tag | |
echo "tag=$tag" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64 | |
- name: Build the docker image | |
run: | | |
docker buildx ls | |
docker buildx build -t yansongda/php --platform ${{ matrix.platform }} -f ./${{ matrix.php-version }}/${{ matrix.php-mode }}/${{ matrix.system }}/Dockerfile ./${{ matrix.php-version }}/${{ matrix.php-mode }} | |
- name: Tag the image | |
run: | | |
docker tag yansongda/php yansongda/php:$tag | |
docker tag yansongda/php registry.cn-shenzhen.aliyuncs.com/yansongda/php:$tag | |
- name: Push the image to docker registry | |
run: | | |
echo $DOCKERHUB_TOKEN | docker login --username yansongda --password-stdin | |
docker push yansongda/php:$tag | |
docker logout | |
- name: Push the image to aliyun registry | |
run: | | |
echo $ALIYUN_IMAGE_TOKEN | docker login --username=yansongda registry.cn-shenzhen.aliyuncs.com --password-stdin | |
docker push registry.cn-shenzhen.aliyuncs.com/yansongda/php:$tag | |
docker logout | |
manifest: | |
name: Manifest ${{ matrix.php-mode }}-${{ matrix.php-version }}-${{ matrix.system }} | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: | |
- '8.1' | |
- '8.2' | |
- '8.3' | |
php-mode: | |
- fpm | |
- cli | |
system: | |
- alpine | |
- bookworm | |
env: | |
PLATFORMS: "linux/arm64 linux/amd64" | |
steps: | |
- name: Recognize manifest | |
run: | | |
tag=${{ matrix.php-mode }}-${{ matrix.php-version }}-${{ matrix.system }} | |
echo $tag | |
echo "tag=$tag" >> $GITHUB_ENV | |
- name: Push the manifest to docker registry | |
run: | | |
echo $DOCKERHUB_TOKEN | docker login --username yansongda --password-stdin | |
list=$(echo $PLATFORMS | sed 's/linux\///g') | |
hub='' | |
for platform in $list; | |
do | |
hub=$hub'yansongda/php:'$platform'-'$tag' ' | |
done | |
docker manifest create yansongda/php:$tag $hub | |
docker manifest push yansongda/php:$tag | |
docker logout | |
- name: Push the manifest to aliyun registry | |
run: | | |
echo $ALIYUN_IMAGE_TOKEN | docker login --username=yansongda registry.cn-shenzhen.aliyuncs.com --password-stdin | |
list=$(echo $PLATFORMS | sed 's/linux\///g') | |
aliyun='' | |
for platform in $list; | |
do | |
aliyun=$aliyun'registry.cn-shenzhen.aliyuncs.com/yansongda/php:'$platform'-'$tag' ' | |
done | |
docker manifest create registry.cn-shenzhen.aliyuncs.com/yansongda/php:$tag $aliyun | |
docker manifest push registry.cn-shenzhen.aliyuncs.com/yansongda/php:$tag | |
docker logout |