Skip to content

Commit 7da08ed

Browse files
committed
feat: github ci
1 parent f9a51dc commit 7da08ed

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/build.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Publish Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
- "v*.*"
8+
tags:
9+
- "v*.*.*"
10+
11+
pull_request:
12+
13+
jobs:
14+
push_to_registry:
15+
name: Push Docker image to Docker Hub
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
packages: write
20+
contents: read
21+
22+
steps:
23+
- name: Check out the repo
24+
uses: actions/checkout@v2
25+
26+
- name: Log in to Docker Hub
27+
if: github.event_name != 'pull_request'
28+
uses: docker/login-action@vv1.12.0
29+
with:
30+
username: ${{ secrets.DOCKER_USERNAME }}
31+
password: ${{ secrets.DOCKER_PASSWORD }}
32+
33+
- name: Set up QEMU
34+
uses: docker/setup-qemu-action@v1
35+
36+
- name: Set up Docker Buildx
37+
uses: docker/setup-buildx-action@v1
38+
39+
- name: Log in to the Container registry
40+
if: github.event_name != 'pull_request'
41+
uses: docker/login-action@vv1.12.0
42+
with:
43+
registry: ghcr.io
44+
username: ${{ github.actor }}
45+
password: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Extract metadata (tags, labels) for Docker
48+
id: meta
49+
uses: docker/metadata-action@v3
50+
with:
51+
images: |
52+
coderockr/php-fpm
53+
ghcr.io/${{ github.repository }}
54+
tags: |
55+
type=schedule
56+
type=ref,event=branch
57+
type=ref,event=pr
58+
type=semver,pattern={{version}}
59+
type=semver,pattern={{major}}.{{minor}}
60+
type=semver,pattern={{major}}
61+
type=sha
62+
63+
- name: Build and push Docker image
64+
uses: docker/build-push-action@v2.7.0
65+
with:
66+
context: .
67+
push: ${{ github.event_name != 'pull_request' }}
68+
tags: ${{ steps.meta.outputs.tags }}
69+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)