Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor how images are pushed #138

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions .ci/publish-bundle-images.sh

This file was deleted.

29 changes: 0 additions & 29 deletions .ci/publish-images.sh

This file was deleted.

31 changes: 0 additions & 31 deletions .ci/tagAndPushFunc.sh

This file was deleted.

5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ updates:
directory: "/"
schedule:
interval: daily

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
58 changes: 58 additions & 0 deletions .github/workflows/publish-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: "Publish images"

on:
push:
branches: [master]
release:
types: [published]

jobs:
publish-containers:
name: Publish container images
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- name: Set env vars for the job
run: |
grep -v '\#' versions.txt | grep opentelemetry-collector | awk -F= '{print "OTELCOL_VERSION="$2}' >> $GITHUB_ENV
echo "VERSION_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
echo "VERSION=$(git describe --tags | sed 's/^v//')" >> $GITHUB_ENV

- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crazy-max? Should we be depending on someone named crazy-max? :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the exact thought. Unfortunately, the official docs for the Docker action recommends this one dynamic labels and tags.

with:
images: otel/opentelemetry-operator,quay.io/opentelemetry/opentelemetry-operator
tag-sha: true

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Build and push Operator image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
build-args: |
VERSION_PKG=github.com/open-telemetry/opentelemetry-operator/internal/version
VERSION=${VERSION}
VERSION_DATE=${VERSION_DATE}
OTELCOL_VERSION=${OTELCOL_VERSION}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
16 changes: 0 additions & 16 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,6 @@ jobs:
- name: "generate release resources"
run: make release-artifacts IMG_PREFIX="quay.io/opentelemetry"

- name: "publish the images"
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
run: ./.ci/publish-images.sh

- name: "publish the bundle image"
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
run: ./.ci/publish-bundle-images.sh

- name: "create the release in GitHub"
env:
GH_WRITE_TOKEN: ${{ secrets.GH_WRITE_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ make cert-manager
Once it's ready, the following can be used to build and deploy a manager, along with the required webhook configuration:

```
make manifests docker-build docker-push deploy
make manifests container container-push deploy
```

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:
Expand Down
15 changes: 7 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ set-image-controller: manifests kustomize
deploy: set-image-controller
$(KUSTOMIZE) build config/default | kubectl apply -f -

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

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

# Build the docker image
docker-build: test
# Build the container image, used only for local dev purposes
container: test
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} .

# Push the docker image
docker-push:
# Push the container image, used only for local dev purposes
container-push:
docker push ${IMG}

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

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

Expand Down