Skip to content

Commit 3a39ff6

Browse files
authored
Publish images for releases and main branch with Actions (#138)
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
1 parent 06bfecd commit 3a39ff6

8 files changed

+71
-116
lines changed

.ci/publish-bundle-images.sh

-31
This file was deleted.

.ci/publish-images.sh

-29
This file was deleted.

.ci/tagAndPushFunc.sh

-31
This file was deleted.

.github/dependabot.yml

+5
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ updates:
44
directory: "/"
55
schedule:
66
interval: daily
7+
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "daily"

.github/workflows/publish-images.yaml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: "Publish images"
2+
3+
on:
4+
push:
5+
branches: [master]
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
publish-containers:
11+
name: Publish container images
12+
runs-on: ubuntu-20.04
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Set env vars for the job
17+
run: |
18+
grep -v '\#' versions.txt | grep opentelemetry-collector | awk -F= '{print "OTELCOL_VERSION="$2}' >> $GITHUB_ENV
19+
echo "VERSION_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
20+
echo "VERSION=$(git describe --tags | sed 's/^v//')" >> $GITHUB_ENV
21+
22+
- name: Docker meta
23+
id: docker_meta
24+
uses: crazy-max/ghaction-docker-meta@v1
25+
with:
26+
images: otel/opentelemetry-operator,quay.io/opentelemetry/opentelemetry-operator
27+
tag-sha: true
28+
29+
- name: Set up QEMU
30+
uses: docker/setup-qemu-action@v1
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v1
34+
35+
- name: Cache Docker layers
36+
uses: actions/cache@v2
37+
with:
38+
path: /tmp/.buildx-cache
39+
key: ${{ runner.os }}-buildx-${{ github.sha }}
40+
restore-keys: |
41+
${{ runner.os }}-buildx-
42+
43+
- name: Build and push Operator image
44+
uses: docker/build-push-action@v2
45+
with:
46+
context: .
47+
file: ./Dockerfile
48+
platforms: linux/amd64
49+
push: ${{ github.event_name != 'pull_request' }}
50+
tags: ${{ steps.docker_meta.outputs.tags }}
51+
labels: ${{ steps.docker_meta.outputs.labels }}
52+
build-args: |
53+
VERSION_PKG=github.com/open-telemetry/opentelemetry-operator/internal/version
54+
VERSION=${VERSION}
55+
VERSION_DATE=${VERSION_DATE}
56+
OTELCOL_VERSION=${OTELCOL_VERSION}
57+
cache-from: type=local,src=/tmp/.buildx-cache
58+
cache-to: type=local,dest=/tmp/.buildx-cache

.github/workflows/release.yaml

-16
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,6 @@ jobs:
2323
- name: "generate release resources"
2424
run: make release-artifacts IMG_PREFIX="quay.io/opentelemetry"
2525

26-
- name: "publish the images"
27-
env:
28-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
29-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
30-
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
31-
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
32-
run: ./.ci/publish-images.sh
33-
34-
- name: "publish the bundle image"
35-
env:
36-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
37-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
38-
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
39-
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
40-
run: ./.ci/publish-bundle-images.sh
41-
4226
- name: "create the release in GitHub"
4327
env:
4428
GH_WRITE_TOKEN: ${{ secrets.GH_WRITE_TOKEN }}

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ make cert-manager
4747
Once it's ready, the following can be used to build and deploy a manager, along with the required webhook configuration:
4848

4949
```
50-
make manifests docker-build docker-push deploy
50+
make manifests container container-push deploy
5151
```
5252

5353
By default, it will generate an image following the format `quay.io/${USER}/opentelemetry-operator:${VERSION}`. You can set the following env vars in front of the `make` command to override parts or the entirety of the image:

Makefile

+7-8
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,10 @@ set-image-controller: manifests kustomize
7272
deploy: set-image-controller
7373
$(KUSTOMIZE) build config/default | kubectl apply -f -
7474

75-
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
76-
release-artifacts: set-image-controller bundle
75+
# Generates the released manifests
76+
release-artifacts: set-image-controller
7777
mkdir -p dist
7878
$(KUSTOMIZE) build config/default -o dist/opentelemetry-operator.yaml
79-
tar czf dist/bundle.tar.gz bundle
8079

8180
# Generate manifests e.g. CRD, RBAC etc.
8281
manifests: controller-gen
@@ -94,12 +93,12 @@ vet:
9493
generate: controller-gen
9594
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
9695

97-
# Build the docker image
98-
docker-build: test
96+
# Build the container image, used only for local dev purposes
97+
container: test
9998
docker build -t ${IMG} --build-arg VERSION_PKG=${VERSION_PKG} --build-arg VERSION=${VERSION} --build-arg VERSION_DATE=${VERSION_DATE} --build-arg OTELCOL_VERSION=${OTELCOL_VERSION} .
10099

101-
# Push the docker image
102-
docker-push:
100+
# Push the container image, used only for local dev purposes
101+
container-push:
103102
docker push ${IMG}
104103

105104
cert-manager:
@@ -160,7 +159,7 @@ bundle: operator-sdk manifests
160159
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
161160
$(OPERATOR_SDK) bundle validate ./bundle
162161

163-
# Build the bundle image.
162+
# Build the bundle image, used only for local dev purposes
164163
bundle-build:
165164
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
166165

0 commit comments

Comments
 (0)