Skip to content

Commit c4c41ad

Browse files
committed
Switch to github actions
1 parent 75abe31 commit c4c41ad

File tree

3 files changed

+70
-32
lines changed

3 files changed

+70
-32
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# File: .github/workflows/docker-build-push.yml
2+
name: Build and Push PHP Docker Image
3+
4+
# Trigger on pushes to master (branch) and on all Git tags
5+
on:
6+
push:
7+
branches:
8+
- master
9+
tags:
10+
- '*'
11+
12+
# Shared environment variables
13+
env:
14+
PHP_VERSION: '8.3'
15+
DOCKER_REPO: 'cyberpearuk/php-build-docker'
16+
17+
jobs:
18+
build-and-push:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
# 1) Check out your code so Docker can see the Dockerfile, context, etc.
23+
- name: Checkout repository
24+
uses: actions/checkout@v3
25+
26+
# 2) Set up Buildx (needed for docker/build-push-action)
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v2
29+
30+
# 3) Log in to Docker Hub (uses your repo secrets)
31+
- name: Log in to Docker Hub
32+
uses: docker/login-action@v2
33+
with:
34+
registry: docker.io
35+
username: ${{ secrets.DOCKER_USERNAME }}
36+
password: ${{ secrets.DOCKER_PASSWORD }}
37+
38+
# 4a) If this is a push to main → build & push two tags:
39+
# • $DOCKER_REPO:$PHP_VERSION
40+
# • $DOCKER_REPO:latest
41+
- name: Build & push (main branch)
42+
if: github.ref == 'refs/heads/master'
43+
uses: docker/build-push-action@v4
44+
with:
45+
context: .
46+
builder: default
47+
platforms: linux/amd64
48+
build-args: |
49+
PHPVERSION=${{ env.PHP_VERSION }}
50+
push: true
51+
tags: |
52+
${{ env.DOCKER_REPO }}:${{ env.PHP_VERSION }}
53+
${{ env.DOCKER_REPO }}:latest
54+
55+
# 4b) If this is a push of a Git tag (e.g. v1.2.3) → build & push two tags:
56+
# • $DOCKER_REPO:<tag>-$PHP_VERSION
57+
# • $DOCKER_REPO:<tag>
58+
- name: Build & push (Git tag)
59+
if: startsWith(github.ref, 'refs/tags/')
60+
uses: docker/build-push-action@v4
61+
with:
62+
context: .
63+
builder: default
64+
platforms: linux/amd64
65+
build-args: |
66+
PHPVERSION=${{ env.PHP_VERSION }}
67+
push: true
68+
tags: |
69+
${{ env.DOCKER_REPO }}:${{ github.ref_name }}-${{ env.PHP_VERSION }}
70+
${{ env.DOCKER_REPO }}:${{ github.ref_name }}

hooks/build

Lines changed: 0 additions & 18 deletions
This file was deleted.

hooks/push

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)