Skip to content

Commit

Permalink
Updated Makefile & Workflow to use .env file
Browse files Browse the repository at this point in the history
Signed-off-by: Lucifergene <47265560+Lucifergene@users.noreply.github.com>
  • Loading branch information
Lucifergene committed Aug 12, 2024
1 parent 1098d3c commit b23cc1e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,15 @@ jobs:
- name: Set up ko
uses: ko-build/setup-ko@v0.6
env:
KO_DOCKER_REPO: quay.io/avik6028
KO_DOCKER_REPO: quay.io/openshift-console
- name: Lint
run: make lint
- name: Build
env:
auth_token: ${{ secrets.QUAY_AUTH_TOKEN }}
run: |
echo "${auth_token}" | ko login quay.io --username ${{ secrets.QUAY_USER_NAME }} --password-stdin
make container-build
run: make container-build
- name: Test
run: make test
- name: Push
env:
auth_token: ${{ secrets.QUAY_AUTH_TOKEN }}
run: |
echo "${auth_token}" | ko login quay.io --username ${{ secrets.QUAY_USER_NAME }} --password-stdin
make container-push
QUAY_USER_NAME: ${{ secrets.QUAY_USER_NAME }}
QUAY_AUTH_TOKEN: ${{ secrets.QUAY_AUTH_TOKEN }}
run: make container-push
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
endif
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)

# Load the environment variables from the .env file
# This is useful for local development and testing.
# You can also set the environment variables directly in the CI/CD pipeline.
# To use the .env file, you can create a .env file in the root of the project and define the variables.
ifneq (,$(wildcard ./.env))
include .env
endif


# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images.
# This variable is used to construct full image tags for bundle and catalog images.
#
Expand All @@ -35,6 +44,7 @@ IMAGE_NAMESPACE ?= openshift-console
IMAGE_REPO ?= $(IMAGE_HOST)/$(IMAGE_NAMESPACE)
IMAGE_TAG_BASE ?= $(IMAGE_REPO)/console-application-operator


# TAG allows the tag for the operator image to be changed. Defaults to the VERSION
TAG ?= $(VERSION)

Expand Down Expand Up @@ -169,8 +179,14 @@ run: manifests generate fmt vet ## Run a controller from your host.
container-build: test ko ## Build the container image with the operator.
KO_DOCKER_REPO=${IMAGE_REPO} $(KO) build . --push=false ${KO_OPTS}

.PHONY: print-auth
print-auth: ## Print the environment variables.
@echo "Username: ${QUAY_USER_NAME}"
@echo "Password: ${QUAY_AUTH_TOKEN}"

.PHONY: container-push
container-push: ## Push the container image with the operator.
echo "${QUAY_AUTH_TOKEN}" | ko login quay.io --username ${QUAY_USER_NAME} --password-stdin
KO_DOCKER_REPO=${IMAGE_REPO} $(KO) build . ${KO_OPTS}

# If you wish to build the manager image targeting other platforms you can use the --platform flag.
Expand Down

0 comments on commit b23cc1e

Please sign in to comment.