-
Notifications
You must be signed in to change notification settings - Fork 0
181 lines (157 loc) · 5.76 KB
/
release-artifacts.yaml
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
171
172
173
174
175
176
177
178
179
180
181
name: Release Artifacts
on:
push:
branches:
- main
jobs:
get-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract_version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Extract version from file
id: extract_version
run: echo "::set-output name=version::$(cat VERSION)"
new-version-check:
needs: get-version
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.check_image.outputs.should_release }}
steps:
- name: Check if Docker image exists with current version
id: check_image
env:
VERSION: ${{ needs.get-version.outputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
REGISTRY="ghcr.io"
REPO="dyllamt/coinbase-producer"
TAG="$VERSION"
MANIFEST_URL="https://$REGISTRY/v2/$REPO/manifests/$TAG"
AUTH_HEADER="Authorization: Bearer $GITHUB_TOKEN"
ACCEPT_HEADER="Accept: application/vnd.docker.distribution.manifest.v2+json"
HEADERS="-H \"$ACCEPT_HEADER\" -H \"$AUTH_HEADER\""
CURL_OPTIONS="-f -sL"
if curl $CURL_OPTIONS $HEADERS "$MANIFEST_URL" > /dev/null; then
echo "Docker image with version $VERSION exists."
echo "should_release=false" >> $GITHUB_OUTPUT
else
echo "Docker image with version $VERSION does not exist."
echo "should_release=true" >> $GITHUB_OUTPUT
fi
docker-push:
needs: [get-version, new-version-check]
if: ${{ needs.new-version-check.outputs.should_release == 'true' }}
permissions:
packages: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ghcr.io/dyllamt/coinbase-producer:${{ needs.get-version.outputs.version }},ghcr.io/dyllamt/coinbase-producer:latest
helm-push:
needs: [get-version, new-version-check]
if: ${{ needs.new-version-check.outputs.should_release == 'true' }}
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: '3.13.3'
- name: Log in to the OCI Registry
run: helm registry login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
- name: Package and Push coinbase-kafka Chart as OCI Artifact
run: |
VERSION=${{ needs.get-version.outputs.version }}
CHART_NAME="coinbase-kafka"
CHART_PATH="charts/$CHART_NAME"
# Update Chart.yaml version
sed -i "s/version: .*/version: $VERSION/" "$CHART_PATH/Chart.yaml"
# Package and push
CHART_REF="ghcr.io/dyllamt/charts/$CHART_NAME:$VERSION"
helm package $CHART_PATH --version $VERSION --app-version $VERSION
helm push $CHART_NAME-$VERSION.tgz $CHART_REF
- name: Package and Push coinbase-producer Chart as OCI Artifact
run: |
VERSION=${{ needs.get-version.outputs.version }}
CHART_NAME="coinbase-producer"
CHART_PATH="charts/$CHART_NAME"
# Update Chart.yaml version
sed -i "s/version: .*/version: $VERSION/" "$CHART_PATH/Chart.yaml"
# Update values.yaml image tag
IMAGE_TAG="ghcr.io/dyllamt/$CHART_NAME:$VERSION"
sed -i "s|image: .*|image: $IMAGE_TAG|" "$CHART_PATH/values.yaml"
# Package and push
CHART_REF="ghcr.io/dyllamt/charts/$CHART_NAME:$VERSION"
helm package $CHART_PATH --version $VERSION --app-version $VERSION
helm push $CHART_NAME-$VERSION.tgz $CHART_REF
helm-docs:
needs: [get-version, new-version-check]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
ref: 'main'
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '^1.17'
- name: Generate Documentation
run: |
go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest
cd charts
for d in */ ; do
helm-docs -c $d
done
- name: Checkout gh-pages Branch
uses: actions/checkout@v3
with:
ref: 'gh-pages'
path: 'gh-pages'
- name: Copy Documentation to gh-pages
run: |
for CHART_DIR in charts/*; do
if [ -d "$CHART_DIR" ]; then # Ensure it's a directory
CHART_NAME=$(basename $CHART_DIR)
# Create a matching directory structure in gh-pages
mkdir -p gh-pages/$CHART_NAME
# Copy the README.md for the chart
cp $CHART_DIR/README.md gh-pages/$CHART_NAME/
fi
done
- name: Commit and Push Changes to gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd gh-pages
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git add .
git commit -m "Update documentation" -a || echo "No changes to commit"
git push origin gh-pages