Skip to content

Commit 66fba07

Browse files
committed
feat: add production build
1 parent 4bf6d19 commit 66fba07

File tree

2 files changed

+96
-12
lines changed

2 files changed

+96
-12
lines changed

.github/workflows/build-latest.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,17 @@ jobs:
7070
with:
7171
platforms: arm64
7272

73-
- name: 🛠️ Setup Docker Buildx
73+
- name: 🛠️ Setup docker Buildx
7474
uses: docker/setup-buildx-action@v2
7575
with:
7676
install: true
7777

78-
- name: 🚀 Build and Export to Docker
78+
- name: 🚀 Build image and push to docker-hub
7979
uses: docker/build-push-action@v4
8080
with:
8181
context: ./dist/base/${{ env.IMAGE_TEMPLATE }}
82+
platforms: linux/amd64,linux/arm64
83+
push: ${{ github.event_name != 'pull_request' }}
8284
load: true
8385
tags: ${{ steps.meta.outputs.tags }}
8486
cache-from: type=gha
@@ -88,14 +90,4 @@ jobs:
8890
- name: 🧪 Test Docker image with "latest" tag
8991
run: IMAGE_TAG=${{ env.IMAGE_TAG }} make test
9092

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-
10193
...

.github/workflows/build-release.yml

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

0 commit comments

Comments
 (0)