-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (108 loc) · 3.83 KB
/
Copy pathbuild.yml
File metadata and controls
124 lines (108 loc) · 3.83 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Build and Push Docker Images
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
environment: Production
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v3.5.0
with:
cosign-release: 'v2.2.4'
- name: Filter changed paths
id: filter
uses: dorny/paths-filter@v2
with:
filters: |
backend:
- 'backend/**'
- 'Dockerfile'
- '.dockerignore'
geocoder:
- 'geocoder/**'
- name: Get Version
id: version
run: |
touch local.properties
VERSION=$(./gradlew -q version)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create Firebase Admin Key File
if: steps.filter.outputs.backend == 'true'
run: |
echo "${{ secrets.FIREBASE_ADMIN_KEY_BASE64 }}" | base64 -d > backend/src/main/resources/firebase-admin-key.json
- name: Extract Docker Metadata for Backend
if: steps.filter.outputs.backend == 'true'
id: backend_metadata
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/backend
tags: |
type=raw,value=${{ env.VERSION }}
- name: Build and push backend image
if: steps.filter.outputs.backend == 'true'
id: build_backend
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.backend_metadata.outputs.tags }}
labels: ${{ steps.backend_metadata.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Extract Docker Metadata for Geocoder
if: steps.filter.outputs.geocoder == 'true'
id: geocoder_metadata
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/geocoder
tags: |
type=raw,value=${{ env.VERSION }}
- name: Build and push geocoder image
if: steps.filter.outputs.geocoder == 'true'
id: build_geocoder
uses: docker/build-push-action@v5
with:
context: geocoder
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.geocoder_metadata.outputs.tags }}
labels: ${{ steps.geocoder_metadata.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Sign the backend Docker image
if: steps.filter.outputs.backend == 'true' && github.event_name == 'push'
env:
TAGS: ${{ steps.backend_metadata.outputs.tags }}
DIGEST: ${{ steps.build_backend.outputs.digest }}
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
- name: Sign the geocoder Docker image
if: steps.filter.outputs.geocoder == 'true' && github.event_name == 'push'
env:
TAGS: ${{ steps.geocoder_metadata.outputs.tags }}
DIGEST: ${{ steps.build_geocoder.outputs.digest }}
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}