Skip to content

Commit 8fb7d6b

Browse files
authored
Merge pull request #22 from wayofdev/feat/refactor
feat: add production build
2 parents 4bf6d19 + c337192 commit 8fb7d6b

File tree

2 files changed

+101
-15
lines changed

2 files changed

+101
-15
lines changed

.github/workflows/build-latest.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ jobs:
1818
fail-fast: true
1919
matrix:
2020
os_name: ["alpine"]
21-
php_version: ["8.1", "8.2"]
22-
php_type: ["fpm", "cli", "supervisord"]
21+
php_version: ["8.1"]
22+
php_type: ["fpm"]
23+
# php_version: ["8.1", "8.2"]
24+
# php_type: ["fpm", "cli", "supervisord"]
2325
environment:
2426
name: latest
2527
url: https://hub.docker.com/r/wayofdev/php-base/tags?page=1&name=latest
@@ -70,16 +72,17 @@ jobs:
7072
with:
7173
platforms: arm64
7274

73-
- name: 🛠️ Setup Docker Buildx
75+
- name: 🛠️ Setup docker Buildx
7476
uses: docker/setup-buildx-action@v2
7577
with:
7678
install: true
7779

78-
- name: 🚀 Build and Export to Docker
80+
- name: 🚀 Build image and push to docker-hub
7981
uses: docker/build-push-action@v4
8082
with:
8183
context: ./dist/base/${{ env.IMAGE_TEMPLATE }}
82-
load: true
84+
platforms: linux/amd64,linux/arm64
85+
push: ${{ github.event_name != 'pull_request' }}
8386
tags: ${{ steps.meta.outputs.tags }}
8487
cache-from: type=gha
8588
cache-to: type=gha,mode=max
@@ -88,14 +91,4 @@ jobs:
8891
- name: 🧪 Test Docker image with "latest" tag
8992
run: IMAGE_TAG=${{ env.IMAGE_TAG }} make test
9093

91-
- name: 📤 Push Docker image
92-
uses: docker/build-push-action@v4
93-
with:
94-
context: ./dist/base/${{ env.IMAGE_TEMPLATE }}
95-
platforms: linux/amd64,linux/arm64
96-
push: ${{ github.event_name != 'pull_request' }}
97-
tags: ${{ steps.meta.outputs.tags }}
98-
cache-from: type=gha
99-
cache-to: type=gha,mode=max
100-
10194
...

.github/workflows/build-release.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
3+
on: # yamllint disable-line rule:truthy
4+
release:
5+
types:
6+
- released
7+
8+
name: 🚀 Build docker images with release tag
9+
10+
jobs:
11+
build:
12+
runs-on: "ubuntu-latest"
13+
strategy:
14+
fail-fast: true
15+
matrix:
16+
os_name: ["alpine"]
17+
php_version: [ "8.1" ]
18+
php_type: [ "fpm" ]
19+
# php_version: ["8.1", "8.2"]
20+
# php_type: ["fpm", "cli", "supervisord"]
21+
environment:
22+
name: release
23+
url: https://hub.docker.com/r/wayofdev/php-base/tags?page=1
24+
25+
steps:
26+
- name: 📦 Check out the codebase
27+
uses: actions/checkout@v3
28+
29+
- name: 🛠️ Install goss and dgoss
30+
uses: e1himself/[email protected]
31+
32+
- name: 🌎 Set environment variables
33+
env:
34+
IMAGE_NAMESPACE: wayofdev/php-base
35+
IMAGE_TEMPLATE: ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}
36+
IMAGE_TAG: wayofdev/php-base:${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-${{ env.VERSION }}
37+
run: |
38+
export RELEASE_VERSION="${GITHUB_REF#refs/*/}" \
39+
&& { \
40+
echo "IMAGE_NAMESPACE=${IMAGE_NAMESPACE}"; \
41+
echo "IMAGE_TEMPLATE=${IMAGE_TEMPLATE}"; \
42+
echo "VERSION=${RELEASE_VERSION:1}"; \
43+
} >> "$GITHUB_ENV"
44+
45+
- name: 🤖 Generate dist files
46+
run: make generate
47+
48+
- name: 🐳 Extract docker meta data
49+
id: meta
50+
uses: docker/metadata-action@v4
51+
with:
52+
images: ${{ env.IMAGE_NAMESPACE }}
53+
tags: |
54+
type=raw,event=branch,value=latest
55+
type=ref,event=pr
56+
type=semver,pattern={{version}}
57+
type=semver,pattern={{major}}.{{minor}}
58+
flavor: |
59+
latest=false
60+
prefix=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-
61+
62+
- name: 🔑 Login to docker-hub
63+
if: github.event_name != 'pull_request'
64+
uses: docker/login-action@v2
65+
with:
66+
username: ${{ secrets.DOCKER_USERNAME }}
67+
password: ${{ secrets.DOCKER_TOKEN }}
68+
69+
- name: 🖥️ Setup QEMU
70+
uses: docker/setup-qemu-action@v2
71+
with:
72+
platforms: arm64
73+
74+
- name: 🛠️ Setup docker Buildx
75+
uses: docker/setup-buildx-action@v2
76+
with:
77+
install: true
78+
79+
- name: 🚀 Build image and push to docker-hub
80+
uses: docker/build-push-action@v4
81+
with:
82+
context: ./dist/base/${{ env.IMAGE_TEMPLATE }}
83+
platforms: linux/amd64,linux/arm64
84+
push: ${{ github.event_name != 'pull_request' }}
85+
tags: ${{ steps.meta.outputs.tags }}
86+
cache-from: type=gha
87+
cache-to: type=gha,mode=max
88+
labels: ${{ steps.meta.outputs.labels }}
89+
90+
- name: 🧪 Test Docker image with "version" tag
91+
run: IMAGE_TAG=${{ env.IMAGE_TAG }} make test
92+
93+
...

0 commit comments

Comments
 (0)