Skip to content

Commit

Permalink
Adds github actions
Browse files Browse the repository at this point in the history
changes gh actions, adds few more binaries

fixes build
  • Loading branch information
f41gh7 committed Mar 25, 2021
1 parent 3c5640f commit 740af33
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 2 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/master.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: publish latest
# This workflow will run on master branch
on:
push:
branches:
- 'master'
jobs:
build:
name: build
runs-on: ubuntu-18.04
steps:
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v2.x

- name: Code checkout
uses: actions/checkout@master

- name: build and push to remote registry
env:
TAG: ${{ env.GITHUB_REF_SLUG }}
run: |
echo ${{secrets.REPO_KEY}} | docker login --username ${{secrets.REPO_USER}} --password-stdin
make latest-push
32 changes: 32 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release
on:
release:
types:
- created
jobs:
release:
name: Release on GitHub
runs-on: ubuntu-18.04
steps:
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v2.x

- name: Check out code
uses: actions/checkout@v2

- name: build and push to remote registry
env:
TAG: ${{ env.GITHUB_REF_SLUG }}
run: |
echo ${{secrets.REPO_KEY}} | docker login --username ${{secrets.REPO_USER}} --password-stdin
make release-push
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
ui-web-amd64.zip
ui-web-windows.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
REPO=victoriametrics/ui

BUILDINFO_TAG ?= $(shell echo $$(git describe --long --all | tr '/' '-')$$( \
git diff-index --quiet HEAD -- || echo '-dirty-'$$(git diff-index -u HEAD | openssl sha1 | cut -c 10-17)))

PKG_TAG ?= $(shell git tag -l --points-at HEAD)
ifeq ($(PKG_TAG),)
PKG_TAG := $(BUILDINFO_TAG)
endif


package-via-docker:
cd packages/victoria-metrics-ui &&\
docker build -t ${REPO}:latest -f Dockerfile-web .

release-via-docker: package-via-docker
echo ${PKG_TAG}
docker tag ${REPO}:latest ${REPO}:${PKG_TAG}
docker rm ui-build-${PKG_TAG} 2>> /dev/null || true
docker create --name ui-build-${PKG_TAG} ${REPO}:${PKG_TAG}
docker cp ui-build-${PKG_TAG}:/app/web $(shell pwd)/ui-web-amd64
docker cp ui-build-${PKG_TAG}:/app/web-windows $(shell pwd)/ui-web-windows
zip -r ui-web-amd64.zip ui-web-amd64
zip -r ui-web-windows.zip ui-web-windows
docker rm ui-build-${PKG_TAG}

latest-push: package-via-docker
docker push ${REPO}

release-push: release-via-docker
docker push ${REPO}:${PKG_TAG}
7 changes: 5 additions & 2 deletions packages/victoria-metrics-ui/Dockerfile-web
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ COPY --from=build-static-stage /app/build /build

WORKDIR /build
COPY web/ /build/
RUN CGO_ENABLED=0 go build main.go && chmod +x main
RUN GOOS=linux GOARCH=amd64 GO111MODULE=on CGO_ENABLED=0 go build -o web-amd64 github.com/VictoriMetrics/vmui/ && \
GOOS=windows GOARCH=amd64 GO111MODULE=on CGO_ENABLED=0 go build -o web-windows github.com/VictoriMetrics/vmui/

FROM alpine:3.13.2
USER root
COPY --from=build-web-stage /build/main /app/web

COPY --from=build-web-stage /build/web-amd64 /app/web
COPY --from=build-web-stage /build/web-windows /app/web-windows
RUN adduser -S -D -u 1000 web && chown -R web /app

USER web
Expand Down

0 comments on commit 740af33

Please sign in to comment.