update #200
This file contains hidden or 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: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_IMAGE_REPOSITORY: ghcr.io/${{ github.repository }} | |
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_ACCESSTOKEN }} | |
| DOCKERHUB_IMAGE_REPOSITORY: yansongda/php | |
| ALIYUN_IMAGE_TOKEN: ${{ secrets.ALIYUN_IMAGE_ACCESSTOKEN }} | |
| ALIYUN_IMAGE_REPOSITORY: registry.cn-shenzhen.aliyuncs.com/yansongda/php | |
| jobs: | |
| build: | |
| name: Image ${{ matrix.php-mode }}-${{ matrix.php-version }}-${{ matrix.system }}-${{ matrix.platform }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php-version: | |
| # - '8.5' | |
| - '8.4' | |
| - '8.3' | |
| - '8.2' | |
| - '8.1' | |
| php-mode: | |
| - cli | |
| system: | |
| - alpine | |
| - trixie | |
| 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 app --platform ${{ matrix.platform }} -f ./${{ matrix.php-version }}/${{ matrix.php-mode }}/${{ matrix.system }}/Dockerfile ./${{ matrix.php-version }}/${{ matrix.php-mode }} | |
| - name: Push the image to Aliyun registry | |
| run: | | |
| docker tag app $ALIYUN_IMAGE_REPOSITORY:$tag | |
| echo $ALIYUN_IMAGE_TOKEN | docker login --username=yansongda registry.cn-shenzhen.aliyuncs.com --password-stdin | |
| docker push $ALIYUN_IMAGE_REPOSITORY:$tag | |
| docker logout | |
| - name: Push the image to Docker registry | |
| run: | | |
| docker tag app $DOCKERHUB_IMAGE_REPOSITORY:$tag | |
| echo $DOCKERHUB_TOKEN | docker login --username yansongda --password-stdin | |
| docker push $DOCKERHUB_IMAGE_REPOSITORY:$tag | |
| docker logout | |
| - name: Push the image to Github registry | |
| run: | | |
| docker tag app $GITHUB_IMAGE_REPOSITORY:$tag | |
| echo $GITHUB_TOKEN | docker login --username=${{ github.actor }} ghcr.io --password-stdin | |
| docker push $GITHUB_IMAGE_REPOSITORY:$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.5' | |
| - '8.4' | |
| - '8.3' | |
| - '8.2' | |
| - '8.1' | |
| php-mode: | |
| - cli | |
| system: | |
| - alpine | |
| - trixie | |
| 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 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$ALIYUN_IMAGE_REPOSITORY':'$platform'-'$tag' ' | |
| done | |
| docker manifest create $ALIYUN_IMAGE_REPOSITORY:$tag $aliyun | |
| docker manifest push $ALIYUN_IMAGE_REPOSITORY:$tag | |
| docker logout | |
| - 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$DOCKERHUB_IMAGE_REPOSITORY':'$platform'-'$tag' ' | |
| done | |
| docker manifest create $DOCKERHUB_IMAGE_REPOSITORY:$tag $hub | |
| docker manifest push $DOCKERHUB_IMAGE_REPOSITORY:$tag | |
| docker logout | |
| - name: Push the manifest to Github registry | |
| run: | | |
| echo $GITHUB_TOKEN | docker login --username=${{ github.actor }} ghcr.io --password-stdin | |
| list=$(echo $PLATFORMS | sed 's/linux\///g') | |
| github='' | |
| for platform in $list; | |
| do | |
| github=$github$GITHUB_IMAGE_REPOSITORY':'$platform'-'$tag' ' | |
| done | |
| docker manifest create $GITHUB_IMAGE_REPOSITORY:$tag $github | |
| docker manifest push $GITHUB_IMAGE_REPOSITORY:$tag | |
| docker logout |