Skip to content

Commit

Permalink
add github workflow & update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
FKAJerry committed Mar 25, 2024
1 parent 413b8b7 commit 89f2538
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 8 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/release-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: release-packages

on:
push:
branches:
- master
tags: ["*"]
pull_request:
branches:
- master

env:
# Use docker.io for Docker Hub if empty
REGISTRY_SERVER_ADDRESS: ghcr.io/openinsight-proj
REGISTRY_USER_NAME: ${{ github.repository_owner }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_TOKEN }}

jobs:
setup-environment:
timeout-minutes: 30
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
release-images:
if: github.repository == 'openinsight-proj/etcd-metrics-proxy'
runs-on: ubuntu-latest
needs: [setup-environment]
permissions:
contents: read
packages: write
timeout-minutes: 90
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Login to GitHub Package Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.ACTIONS_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.2.1
- name: Get tag
id: tag
uses: dawidd6/action-get-tag@v1
with:
# Optionally strip `v` prefix
strip_v: true
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.REGISTRY_SERVER_ADDRESS }}/etcd-metrics-proxy:${{steps.tag.outputs.tag}}
24 changes: 16 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
PREFIX := quay.io/roboll/etcd-metrics-proxy
VERSION := $(shell git describe --tags --abbrev=0 HEAD)
ORG=openinsight-proj
PROJECT=etcd-metrics-proxy
REG=quay.io
TAG=0.6.0
PKG=github.com/openinsight-proj/etcd-metrics-proxy

check:
go vet .
Expand All @@ -13,10 +16,15 @@ build:
GOOS=linux go build -a --ldflags '-extldflags "-static"' -tags netgo -installsuffix netgo -o etcd-metrics-proxy .
.PHONY: build

container: build
docker build -t $(PREFIX):$(VERSION) .
.PHONY: container
.PHONY: image/build
image/build: build
docker build -t ${REG}/${ORG}/${PROJECT}:${TAG} .

push: container
docker push $(PREFIX):$(VERSION)
.PHONY: push
# Build and push a multi-architecture docker image
.PHONY: image/buildx
image/buildx: build
docker buildx build --platform linux/amd64,linux/arm64,linux/s390x,linux/ppc64le --push -t ${REG}/${ORG}/${PROJECT}:${TAG} .

.PHONY: image/push
image/push:
docker push ${REG}/${ORG}/${PROJECT}:${TAG}

0 comments on commit 89f2538

Please sign in to comment.