Skip to content

Commit ffa9595

Browse files
committed
Update build-publish.yaml
Update build-publish.yaml Update build-publish.yaml
1 parent e77962c commit ffa9595

1 file changed

Lines changed: 96 additions & 37 deletions

File tree

.github/workflows/build-publish.yaml

Lines changed: 96 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,116 @@ on:
77
schedule:
88
- cron: "30 1 * * 2" # Every Tuesday at 1:30 UTC (7:00 AM IST)
99

10+
permissions:
11+
packages: write
12+
contents: read
13+
14+
env:
15+
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
16+
1017
jobs:
11-
build-and-publish:
18+
build:
1219
runs-on: ubuntu-latest
13-
env:
14-
BUILT_IMAGE_NAME: docker.io/clarity-tech/sail-8.4
20+
strategy:
21+
fail-fast: true
22+
matrix:
23+
platform:
24+
- linux/amd64
25+
- linux/arm64
1526
steps:
1627
- name: Checkout code
1728
uses: actions/checkout@v4
29+
- name: Prepare
30+
run: |
31+
platform=${{ matrix.platform }}
32+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
33+
34+
- name: Login to GitHub Container Registry
35+
uses: docker/login-action@v3
36+
with:
37+
registry: ghcr.io
38+
username: ${{ github.repository_owner }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
1840

19-
- name: Copy .env.example to .env
20-
run: cp .env.example .env
41+
- name: Docker meta
42+
id: meta
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: ${{ env.REGISTRY_IMAGE }}
46+
tags: |
47+
type=ref,event=branch
48+
type=ref,event=tag
49+
type=semver,pattern={{version}}
50+
type=semver,pattern={{major}}.{{minor}}
51+
type=raw,value=latest
52+
type=raw,value=php8.4
2153
22-
- name: Pre-Install Composer Dependencies
23-
run: |
24-
docker run --rm \
25-
-u "$(id -u):$(id -g)" \
26-
-v "$(pwd):/var/www/html" \
27-
-w /var/www/html \
28-
laravelsail/php84-composer:latest \
29-
composer install --ignore-platform-reqs
54+
# - name: Set up QEMU
55+
# uses: docker/setup-qemu-action@v3
3056

3157
- name: Set up Docker Buildx
3258
uses: docker/setup-buildx-action@v3
59+
60+
- name: Build and push
61+
id: build
62+
uses: docker/build-push-action@v6
3363
with:
34-
platforms: linux/amd64,linux/arm64
64+
context: ./docker/8.4
65+
build-args: |
66+
WWWGROUP=20
67+
platforms: ${{ matrix.platform }}
68+
labels: ${{ steps.meta.outputs.labels }}
69+
tags: ${{ steps.meta.outputs.tags }}
70+
outputs: type=image,name-canonical=true,push=true
3571

36-
- name: Login to GitHub Container Registry
37-
uses: docker/login-action@v3
72+
- name: Export digest
73+
run: |
74+
mkdir -p ${{ runner.temp }}/digests
75+
digest="${{ steps.build.outputs.digest }}"
76+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
77+
78+
- name: Upload digest
79+
uses: actions/upload-artifact@v4
3880
with:
39-
registry: ghcr.io
40-
username: ${{ github.actor }}
41-
password: ${{ secrets.GITHUB_TOKEN }}
81+
name: digests-${{ env.PLATFORM_PAIR }}
82+
path: ${{ runner.temp }}/digests/*
83+
if-no-files-found: error
84+
retention-days: 1
85+
86+
merge:
87+
runs-on: ubuntu-latest
88+
needs:
89+
- build
90+
steps:
91+
- name: Download digests
92+
uses: actions/download-artifact@v4
93+
with:
94+
path: ${{ runner.temp }}/digests
95+
pattern: digests-*
96+
merge-multiple: true
97+
98+
- name: Set up Docker Buildx
99+
uses: docker/setup-buildx-action@v3
100+
101+
- name: Docker meta
102+
id: meta
103+
uses: docker/metadata-action@v5
104+
with:
105+
images: ${{ env.REGISTRY_IMAGE }}
106+
tags: |
107+
type=ref,event=branch
108+
type=ref,event=tag
109+
type=semver,pattern={{version}}
110+
type=semver,pattern={{major}}.{{minor}}
111+
type=raw,value=latest
112+
type=raw,value=php8.4
42113
43-
- name: Test Sail Build Docker image
114+
- name: Create manifest list and push
115+
working-directory: ${{ runner.temp }}/digests
44116
run: |
45-
docker images
46-
mv ./docker-compose.yml ./backup-compose.yml
47-
cp .github/compose.yml ./docker-compose.yml
48-
./vendor/bin/sail build
49-
docker images
117+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
118+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
50119
51-
- name: Tag and Push Image
120+
- name: Inspect image
52121
run: |
53-
IMAGE_NAME=ghcr.io/clarity-tech/laravel-strict/8.4
54-
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
55-
docker tag $BUILT_IMAGE_NAME $IMAGE_NAME:${{ github.sha }}
56-
docker push $IMAGE_NAME:${{ github.sha }}
57-
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
58-
VERSION=${GITHUB_REF#refs/tags/}
59-
docker tag $BUILT_IMAGE_NAME $IMAGE_NAME:$VERSION
60-
docker tag $BUILT_IMAGE_NAME $IMAGE_NAME:latest
61-
docker push $IMAGE_NAME:$VERSION
62-
docker push $IMAGE_NAME:latest
63-
fi
122+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}

0 commit comments

Comments
 (0)