Skip to content

Commit

Permalink
Refactor how images are pushed
Browse files Browse the repository at this point in the history
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
  • Loading branch information
jpkrohling committed Dec 14, 2020
1 parent 7b8a9a0 commit ff083f7
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 81 deletions.
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.

81 changes: 81 additions & 0 deletions .github/workflows/publish-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: "Publish images"

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

jobs:
publish-dockerhub:
name: Publish image to Docker Hub
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//')"
- 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: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Login to Quay.io
uses: docker/login-action@v1
with:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Build and push Operator image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
push: true
build-args: |
VERSION_PKG=github.com/open-telemetry/opentelemetry-operator/internal/version
VERSION=${VERSION}
VERSION_DATE=${VERSION_DATE}
OTELCOL_VERSION=${OTELCOL_VERSION}
tags: |
otel/opentelemetry-operator:latest
otel/opentelemetry-operator:${GITHUB_REF}
quay.io/opentelemetry/opentelemetry-operator:latest
quay.io/opentelemetry/opentelemetry-operator:${GITHUB_REF}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Build and push bundle image
uses: docker/build-push-action@v2
with:
context: .
file: ./bundle.Dockerfile
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
push: true
tags: |
otel/opentelemetry-operator-bundle:latest
otel/opentelemetry-operator-bundle:${GITHUB_REF}
quay.io/opentelemetry/opentelemetry-operator-bundle:latest
quay.io/opentelemetry/opentelemetry-operator-bundle:${GITHUB_REF}
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
63 changes: 63 additions & 0 deletions .github/workflows/remove-me-before-merging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "Remove me before merging"

on:
pull_request:
branches: [master]

jobs:
publish-dockerhub:
name: Publish image to Docker Hub
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=latest"
- 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/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
push: false
build-args: |
VERSION_PKG=github.com/open-telemetry/opentelemetry-operator/internal/version
VERSION=${VERSION}
VERSION_DATE=${VERSION_DATE}
OTELCOL_VERSION=${OTELCOL_VERSION}
tags: |
otel/opentelemetry-operator:latest
quay.io/opentelemetry/opentelemetry-operator:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Build and push bundle image
uses: docker/build-push-action@v2
with:
context: .
file: ./bundle.Dockerfile
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
push: false
tags: |
otel/opentelemetry-operator-bundle:latest
quay.io/opentelemetry/opentelemetry-operator-bundle:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
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 container 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
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ vet:
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

# Build the docker image
# 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 +160,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

0 comments on commit ff083f7

Please sign in to comment.