Skip to content

Commit 409b46c

Browse files
committed
#39 feat: add workflow to public php container
1 parent c7961f8 commit 409b46c

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Publish Docker image
2+
3+
on:
4+
push:
5+
branches: [ "*" ]
6+
pull_request:
7+
branches: [ "*" ]
8+
9+
env:
10+
DOCKER_ID: ${{ secrets.DOCKER_ID }}
11+
IMAGE_NAME: blog-php
12+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
13+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
14+
15+
jobs:
16+
shellcheck:
17+
name: Shellcheck
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
name: Checkout repository
22+
23+
- name: Copy .env.example to .env
24+
run: cp .env.example .env
25+
26+
- name: Run ShellCheck
27+
uses: ludeeus/action-shellcheck@master
28+
with:
29+
check_together: 'yes'
30+
ignore_paths: >-
31+
sources
32+
33+
push_to_registry:
34+
if: github.event_name != 'pull_request'
35+
name: Build and push Docker image
36+
needs: shellcheck
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
42+
- name: Setup Docker Buildx
43+
uses: docker/setup-buildx-action@v3
44+
45+
- name: Log into Docker Hub
46+
uses: docker/login-action@v3
47+
with:
48+
username: ${{ env.DOCKER_USERNAME }}
49+
password: ${{ env.DOCKER_PASSWORD }}
50+
51+
- name: Extract Docker metadata
52+
id: meta
53+
uses: docker/metadata-action@v5
54+
with:
55+
images: ${{ env.DOCKER_ID }}/${{ env.IMAGE_NAME }}
56+
57+
- name: Build and push Docker image
58+
id: build-and-push
59+
uses: docker/build-push-action@v6
60+
with:
61+
context: .
62+
file: php/Dockerfile
63+
push: true
64+
tags: ${{ steps.meta.outputs.tags }}
65+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)