GHA fixes

This commit is contained in:
Khanh Ngo 2023-05-24 21:21:44 +02:00
parent 5183bb5093
commit 8ac33a0278
No known key found for this signature in database
GPG key ID: 29077342AA5648F6
4 changed files with 18 additions and 17 deletions

View file

@ -9,16 +9,16 @@ on:
jobs:
build-image:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
# set environment
- name: Set BUILD_TIME env
run: echo "BUILD_TIME=$(date)" >> $GITHUB_ENV
- name: Set COMMIT env
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Set GIT_COMMIT env
run: echo "GIT_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Environment printer
uses: managedkaos/print-env@v1.0
@ -88,11 +88,11 @@ jobs:
with:
push: true
context: .
platforms: linux/amd64,linux/arm/v7
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: ${{ steps.image-tags.outputs.container_images }}
build-args: |
APP_VERSION=${{ env.APP_VERSION }}
BUILD_TIME=${{ env.BUILD_TIME }}
COMMIT=${{ env.SHORT_SHA }}
GIT_COMMIT=${{ env.GIT_COMMIT }}
cache-from: type=gha
cache-to: type=gha,mode=max

View file

@ -7,7 +7,7 @@ on:
jobs:
releases-matrix:
name: Release Go Binary
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
# build and publish in parallel: linux/386, linux/amd64, darwin/386, darwin/amd64
@ -24,7 +24,7 @@ jobs:
- 7
steps:
# get the source code
- uses: actions/checkout@v2
- uses: actions/checkout@v3
# set environment
- name: Set APP_VERSION env

View file

@ -1,12 +1,13 @@
# Build stage
FROM golang:1.17-alpine3.16 as builder
LABEL maintainer="Khanh Ngo <k@ndk.name"
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.17-alpine3.16 as builder
LABEL maintainer="Khanh Ngo <k@ndk.name>"
ARG TARGETOS=linux
ARG TARGETARCH=amd64
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG APP_VERSION=dev
ARG BUILD_TIME=""
ARG COMMIT=""
ARG BUILD_TIME
ARG GIT_COMMIT
ARG BUILD_DEPENDENCIES="npm \
yarn"
@ -52,7 +53,7 @@ COPY . /build
RUN cp -r /build/custom/ assets/
# Build
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-X 'main.appVersion=${APP_VERSION}' -X 'main.buildTime=${BUILD_TIME}' -X 'main.gitCommit=${COMMIT}'" -a -o wg-ui .
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-X 'main.appVersion=${APP_VERSION}' -X 'main.buildTime=${BUILD_TIME}' -X 'main.gitCommit=${GIT_COMMIT}'" -a -o wg-ui .
# Release stage
FROM alpine:3.16

View file

@ -195,13 +195,13 @@ feature work.
Go to the project root directory and run the following command:
```sh
docker build --build-arg=COMMIT=$(git rev-parse --short HEAD) -t wireguard-ui .
docker build --build-arg=GIT_COMMIT=$(git rev-parse --short HEAD) -t wireguard-ui .
```
or
```sh
docker compose build --build-arg=COMMIT=$(git rev-parse --short HEAD)
docker compose build --build-arg=GIT_COMMIT=$(git rev-parse --short HEAD)
```
:information_source: A container image is avaialble on [Docker Hub](https://hub.docker.com/r/ngoduykhanh/wireguard-ui) which you can pull and use