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

View file

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

View file

@ -1,12 +1,13 @@
# Build stage # Build stage
FROM golang:1.17-alpine3.16 as builder FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.17-alpine3.16 as builder
LABEL maintainer="Khanh Ngo <k@ndk.name" LABEL maintainer="Khanh Ngo <k@ndk.name>"
ARG TARGETOS=linux ARG BUILDPLATFORM
ARG TARGETARCH=amd64 ARG TARGETOS
ARG TARGETARCH
ARG APP_VERSION=dev ARG APP_VERSION=dev
ARG BUILD_TIME="" ARG BUILD_TIME
ARG COMMIT="" ARG GIT_COMMIT
ARG BUILD_DEPENDENCIES="npm \ ARG BUILD_DEPENDENCIES="npm \
yarn" yarn"
@ -52,7 +53,7 @@ COPY . /build
RUN cp -r /build/custom/ assets/ RUN cp -r /build/custom/ assets/
# Build # 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 # Release stage
FROM alpine:3.16 FROM alpine:3.16

View file

@ -195,13 +195,13 @@ feature work.
Go to the project root directory and run the following command: Go to the project root directory and run the following command:
```sh ```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 or
```sh ```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 :information_source: A container image is avaialble on [Docker Hub](https://hub.docker.com/r/ngoduykhanh/wireguard-ui) which you can pull and use