-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (95 loc) · 3.15 KB
/
Copy pathbuild-push.yaml
File metadata and controls
111 lines (95 loc) · 3.15 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
name: Build and push services
on:
push:
branches: ["main"]
workflow_dispatch:
env:
GCP_REGISTRY: "europe-west2-docker.pkg.dev/cyberark-gitops-3a49df/cyberark-images-3a49df"
jobs:
changes:
runs-on: ubuntu-latest
outputs:
accounts: ${{ steps.filter.outputs.accounts }}
transfers: ${{ steps.filter.outputs.transfers }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Detect changes
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
accounts:
- 'services/accounts/**'
transfers:
- 'services/transfers/**'
build-accounts:
runs-on: ubuntu-latest
needs: changes
if: github.event_name == 'workflow_dispatch' || needs.changes.outputs.accounts == 'true'
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Authenticate to Google Cloud
id: gcloud-auth
uses: google-github-actions/auth@v3
with:
token_format: access_token
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Configure Docker for Artifact Registry
run: |
REGISTRY_HOST=$(echo "$GCP_REGISTRY" | cut -d/ -f1)
echo "Using registry host: $REGISTRY_HOST"
gcloud auth configure-docker "$REGISTRY_HOST" -q
- name: Build and push accounts
env:
SERVICE: accounts
run: |
IMAGE_SHA="${GCP_REGISTRY}/${SERVICE}:${GITHUB_SHA}"
IMAGE_LATEST="${GCP_REGISTRY}/${SERVICE}:latest"
docker build \
-f services/${SERVICE}/Dockerfile \
-t "$IMAGE_SHA" \
-t "$IMAGE_LATEST" \
.
docker push "$IMAGE_SHA"
docker push "$IMAGE_LATEST"
build-transfers:
runs-on: ubuntu-latest
needs: changes
if: github.event_name == 'workflow_dispatch' || needs.changes.outputs.transfers == 'true'
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Authenticate to Google Cloud
id: gcloud-auth
uses: google-github-actions/auth@v3
with:
token_format: access_token
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Configure Docker for Artifact Registry
run: |
REGISTRY_HOST=$(echo "$GCP_REGISTRY" | cut -d/ -f1)
echo "Using registry host: $REGISTRY_HOST"
gcloud auth configure-docker "$REGISTRY_HOST" -q
- name: Build and push transfers
env:
SERVICE: transfers
run: |
IMAGE_SHA="${GCP_REGISTRY}/${SERVICE}:${GITHUB_SHA}"
IMAGE_LATEST="${GCP_REGISTRY}/${SERVICE}:latest"
docker build \
-f services/${SERVICE}/Dockerfile \
-t "$IMAGE_SHA" \
-t "$IMAGE_LATEST" \
.
docker push "$IMAGE_SHA"
docker push "$IMAGE_LATEST"