-
Notifications
You must be signed in to change notification settings - Fork 2
50 lines (42 loc) · 1.79 KB
/
publish-ghcr.yml
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
name: Docker Image CI for Github Container Registry
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
build_and_publish:
runs-on: ubuntu-latest
env:
PG_PASSWORD: ${{ secrets.PG_PASSWORD }}
PG_DATABASE: ${{ secrets.PG_DATABASE }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: ~/.docker
key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile') }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_PAT }}
- name: Build and push Docker image
run: |
# Build and push PostgreSQL service image
docker pull postgres:16.1
docker tag postgres:16.1 ghcr.io/${{ github.repository_owner }}/postgres:16.1
docker push ghcr.io/${{ github.repository_owner }}/postgres:16.1
# Build and push Server service image
docker-compose -f docker-compose.yml build server
docker tag lost-and-found-server-dev:tag-v1.0.0 ghcr.io/${{ github.repository_owner }}/lost-and-found-server-dev:tag-v1.0.0
docker push ghcr.io/${{ github.repository_owner }}/lost-and-found-server-dev:tag-v1.0.0
# Build and push Client service image
docker-compose -f docker-compose.yml build client
docker tag lost-and-found-client-dev:tag-v1.0.0 ghcr.io/${{ github.repository_owner }}/lost-and-found-client-dev:tag-v1.0.0
docker push ghcr.io/${{ github.repository_owner }}/lost-and-found-client-dev:tag-v1.0.0