-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (151 loc) · 5.82 KB
/
docker-build-tag.yml
File metadata and controls
170 lines (151 loc) · 5.82 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Copyright The Linux Foundation and each contributor to LFX.
# SPDX-License-Identifier: MIT
name: Docker Build - Release
on:
push:
tags:
- v*
permissions:
contents: read
id-token: write
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
COSIGN_VERSION: v2.5.3
HELM_VERSION: v3.18.4
jobs:
build-and-push:
runs-on: ubuntu-latest
outputs:
app_version: ${{ steps.prepare.outputs.app_version }}
chart_name: ${{ steps.prepare.outputs.chart_name }}
chart_version: ${{ steps.prepare.outputs.chart_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: OIDC Auth
uses: aws-actions/configure-aws-credentials@v4
with:
audience: sts.amazonaws.com
role-to-assume: arn:aws:iam::372256339901:role/github-actions-deploy
aws-region: us-west-2
- name: Get LaunchDarkly client ID from AWS Secrets Manager
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
LAUNCHDARKLY, /cloudops/managed-secrets/launchdarkly/lfx_one/ld_client_id
- name: Set LaunchDarkly client ID environment variable
run: |
LAUNCHDARKLY_CLIENT_ID=$(echo "$LAUNCHDARKLY" | jq -r '.ld_client_id // empty')
if [ -z "$LAUNCHDARKLY_CLIENT_ID" ]; then
echo "❌ LaunchDarkly client ID not found in AWS Secrets Manager"
exit 1
fi
echo "LAUNCHDARKLY_CLIENT_ID=$LAUNCHDARKLY_CLIENT_ID" >> $GITHUB_ENV
- name: Prepare versions and chart name
id: prepare
run: |
set -euo pipefail
APP_VERSION=$(echo ${{ github.ref_name }} | sed 's/v//g')
CHART_NAME="$(yq '.name' charts/*/Chart.yaml)"
CHART_VERSION="$(yq '.version' charts/*/Chart.yaml)"
{
echo "app_version=$APP_VERSION"
echo "chart_name=$CHART_NAME"
echo "chart_version=$CHART_VERSION"
} >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
labels: |
org.opencontainers.image.title=LFX One UI
org.opencontainers.image.description=Linux Foundation LFX One UI application
org.opencontainers.image.vendor=The Linux Foundation
org.opencontainers.image.licenses=MIT
org.opencontainers.image.documentation=https://github.com/${{ github.repository }}/blob/main/README.md
org.opencontainers.image.source=https://github.com/${{ github.repository }}
com.github.actions.run_id=${{ github.run_id }}
com.github.actions.run_number=${{ github.run_number }}
com.github.actions.workflow=${{ github.workflow }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_ENV=production
secret-envs: |
LAUNCHDARKLY_CLIENT_ID=LAUNCHDARKLY_CLIENT_ID
release-helm-chart:
needs: build-and-push
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write
outputs:
digest: ${{ steps.publish-ghcr.outputs.digest }}
image_name: ${{ steps.publish-ghcr.outputs.image_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Publish Chart to GHCR
id: publish-ghcr
uses: linuxfoundation/lfx-public-workflows/.github/actions/helm-chart-oci-publisher@c465d6571fa0b8be9d551d902955164ea04a00af # main
with:
name: ${{ needs.build-and-push.outputs.chart_name }}
repository: ${{ github.repository }}/chart
chart_version: ${{ needs.build-and-push.outputs.chart_version }}
app_version: ${{ needs.build-and-push.outputs.app_version }}
registry: ghcr.io
registry_username: ${{ github.actor }}
registry_password: ${{ secrets.GITHUB_TOKEN }}
- name: Install Cosign
uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
with:
cosign-release: "${{ env.COSIGN_VERSION }}"
- name: Login to GitHub
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Sign the Helm chart in GHCR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
cosign sign --yes '${{ steps.publish-ghcr.outputs.image_name }}@${{ steps.publish-ghcr.outputs.digest }}'
create-ghcr-helm-provenance:
needs:
- release-helm-chart
permissions:
actions: read
id-token: write
packages: write
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v2.1.0
with:
image: ${{ needs.release-helm-chart.outputs.image_name }}
digest: ${{ needs.release-helm-chart.outputs.digest }}
registry-username: ${{ github.actor }}
secrets:
registry-password: ${{ secrets.GITHUB_TOKEN }}