-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (68 loc) · 2.42 KB
/
Copy pathdocker_ci_cd.yml
File metadata and controls
80 lines (68 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Docker CI/CD
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
REGISTRY: ghcr.io
jobs:
build-and-push-image:
name: Build ${{ matrix.name }} image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- name: sqlserver
provider: sqlserver
image_name: ${{ github.repository }}/database-container
dockerfile: ./src/Dockerfile
smoke_image: sqldockerdeploykit-ci-sqlserver
publish: true
- name: sqlserver-provider-layout
provider: sqlserver
image_name: ${{ github.repository }}/database-container-sqlserver-provider
dockerfile: ./providers/sqlserver/Dockerfile
smoke_image: sqldockerdeploykit-ci-sqlserver-provider
publish: false
- name: postgres
provider: postgres
image_name: ${{ github.repository }}/database-container-postgres
dockerfile: ./providers/postgres/Dockerfile
smoke_image: sqldockerdeploykit-ci-postgres
publish: true
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build smoke-test image
run: docker build -t "${{ matrix.smoke_image }}:${{ github.sha }}" -f "${{ matrix.dockerfile }}" .
- name: Smoke test image
run: bash ./scripts/smoke-test-provider.sh "${{ matrix.provider }}" "${{ matrix.smoke_image }}:${{ github.sha }}"
- name: Log in to the Container registry
if: github.event_name == 'push' && matrix.publish
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
if: matrix.publish
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ matrix.image_name }}
- name: Build and push Docker image
if: matrix.publish
uses: docker/build-push-action@v7
with:
context: .
file: ${{ matrix.dockerfile }}
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}