Skip to content
This repository has been archived by the owner on Sep 14, 2024. It is now read-only.

ko-built saveweb Images #112

ko-built saveweb Images

ko-built saveweb Images #112

Workflow file for this run

name: ko-built saveweb Images
on:
push:
branches:
- 'master'
paths:
- '.github/workflows/saveweb-go.yml'
schedule:
- cron: "20 * * * *"
workflow_dispatch:
env:
REGISTRY_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/saveweb
jobs:
ko-build-images:
name: build images with ko-build
runs-on: ubuntu-24.04
steps:
- name: Fetch the latest tag
shell: bash
run: |
curl() { $(type -P curl) -LRq --retry 5 --retry-delay 10 --retry-max-time 60 --fail "$@"; }
acdanmaku_go_repo='git.saveweb.org/saveweb/acfunction_go'
acdanmaku_go_latest_tag=$(curl -L -- "https://${acdanmaku_go_repo}/tags/list" \
| jq -r .results[] | sort -Vr | head -n 1)
huashijie_go_repo='git.saveweb.org/saveweb/huashijie_go'
huashijie_go_latest_tag=$(curl -L -- "https://${huashijie_go_repo}/tags/list" \
| jq -r .results[] | sort -Vr | head -n 1)
for _var in acdanmaku_go_latest_tag \
huashijie_go_latest_tag; do
if [[ -z "${!_var}" ]]; then
echo "FATAL: ${_var} is empty!"
exit 1
fi
echo "${_var}=${!_var}" >> "$GITHUB_ENV"
done
echo "acdanmaku_go_repo=${acdanmaku_go_repo}" >> "$GITHUB_ENV"
echo "huashijie_go_repo=${huashijie_go_repo}" >> "$GITHUB_ENV"
curl -o '.ko.yaml' -- \
https://raw.githubusercontent.com/saveweb/saveweb-images/master/prod.ko.yaml
- name: Clone the git repos
shell: bash
run: |
git clone -j "$(nproc)" \
--no-tags --shallow-submodules --recurse-submodules --depth 1 --single-branch \
--branch "$acdanmaku_go_latest_tag" \
"https://${acdanmaku_go_repo}.git"
cp .ko.yaml ./acfunction_go/
git clone -j "$(nproc)" \
--no-tags --shallow-submodules --recurse-submodules --depth 1 --single-branch \
--branch "$huashijie_go_latest_tag" \
"https://${huashijie_go_repo}.git"
cp .ko.yaml ./huashijie_go/
- uses: actions/setup-go@v5
with:
go-version: 'stable'
check-latest: true
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: ko-build/[email protected]
env:
KO_DOCKER_REPO: docker.io/${{ env.REGISTRY_IMAGE }}
with:
version: tip
# TODO: issue the ko-build commands in parallel, while keeping the ko command from been installed for several times
- run: ko build ./cmd/... --platform=linux/amd64,linux/arm64 --bare --tags 'acdanmaku'
working-directory: ./acfunction_go
- run: |
rm -f ./.ko.yaml
ko build ./cmd/... --platform=linux/amd64,linux/arm64 --bare --tags 'acdanmaku-debug' --debug
working-directory: ./acfunction_go
- run: ko build ./cmd/... --platform=linux/amd64,linux/arm64 --bare --tags 'huashijie'
working-directory: ./huashijie_go
- run: |
rm -f ./.ko.yaml
ko build ./cmd/... --platform=linux/amd64,linux/arm64 --bare --tags 'huashijie-debug' --debug
working-directory: ./huashijie_go