Skip to content

Commit

Permalink
github action create build env (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
wph95 committed Aug 19, 2022
1 parent 9843f01 commit 21d02e1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,27 @@ jobs:
packages: write

env:
IMAGE_VERSION: "${{ github.event.release.tag_name }}"

RELEASE_VERSION: "${{ github.event.release.tag_name }}"

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

# limit docker push image concurrency to 1
# to avoid github package return 429 ratelimit error
- name: Set docker upload concurrent
run: |
echo $'{"max-concurrent-uploads": 1}' | sudo dd status=none of=/etc/docker/daemon.json
sudo service docker restart
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
Expand All @@ -39,20 +41,12 @@ jobs:

- name: build ghcr docker image
run: make build-docker-images
env:
IMAGE_NAME: "ghcr.io/open-telemetry/demo"

- name: push ghcr image
run: make push-docker-images
env:
IMAGE_NAME: "ghcr.io/open-telemetry/demo"

- name: build dockerhub docker image
run: make build-docker-images
env:
IMAGE_NAME: "otel/demo"

- name: push dockerhub image
run: make push-docker-images
env:
IMAGE_NAME: "otel/demo"
23 changes: 17 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,21 @@ install-tools: $(MISSPELL)
npm install
@echo "All tools installed"

.PHONY: build-docker-images
build-docker-images:
docker compose -f docker-compose.yml build
.PHONY: build-and-push-dockerhub
build-and-push-dockerhub:
docker compose --env-file .dockerhub.env -f docker-compose.yml build
docker compose --env-file .dockerhub.env -f docker-compose.yml pusd

.PHONY: push-docker-images
push-docker-images:
docker compose -f docker-compose.yml push
.PHONY: build-and-push-ghcr
build-and-push-ghcr:
docker compose --env-file .ghcr.env -f docker-compose.yml build
docker compose --env-file .ghcr.env -f docker-compose.yml push

.PHONY: build-env-file
build-env-file:
cp .env .dockerhub.env
sed -i '/IMAGE_VERSION=.*/c\IMAGE_VERSION=${RELEASE_VERSION}' .dockerhub.env
sed -i '/IMAGE_NAME=.*/c\IMAGE_NAME=otel/demo' .dockerhub.env
cp .env .ghcr.env
sed -i '/IMAGE_VERSION=.*/c\IMAGE_VERSION=${RELEASE_VERSION}' .ghcr.env
sed -i '/IMAGE_NAME=.*/c\IMAGE_NAME=ghcr.io/open-telemetry/demo' .ghcr.env

0 comments on commit 21d02e1

Please sign in to comment.