cache-proxy/.gitea/workflows/container-build.yaml

50 lines
2.1 KiB
YAML
Raw Normal View History

2025-02-19 17:49:35 +08:00
name: build container
run-name: build container on ${{ gitea.actor }}
on: [push]
env:
GOPROXY: ${{ vars.GOPROXY }}
jobs:
test:
runs-on: bookworm
steps:
- name: Setup apt mirror
run: sed -i "s,deb.debian.org,${{ vars.DEBIAN_MIRROR }},g" ${{ vars.DEBIAN_APT_SOURCES }}
if: ${{ vars.DEBIAN_MIRROR && vars.DEBIAN_APT_SOURCES }}
- name: Setup Debian environment
run: apt update && apt install -y nodejs
- name: Setup Golang
2025-02-19 17:59:28 +08:00
uses: actions/setup-go@v5
2025-02-19 18:03:40 +08:00
with:
go-version: 1.24.0
2025-02-19 17:49:35 +08:00
- name: Check out repository code
uses: actions/checkout@v4
- name: Run tests
run: go test -v ./...
build-container:
runs-on: bookworm
needs:
- test
steps:
- name: Setup apt mirror
run: sed -i "s,deb.debian.org,${{ vars.DEBIAN_MIRROR }},g" ${{ vars.DEBIAN_APT_SOURCES }}
if: ${{ vars.DEBIAN_MIRROR && vars.DEBIAN_APT_SOURCES }}
- name: Setup debian environment
run: apt update && apt install -y podman podman-compose nodejs
- name: Check out repository code
uses: actions/checkout@v4
- name: Build container
run: REGISTRY=${{ github.server_url}}; REGISTRY=${REGISTRY##https://}; REGISTRY=${REGISTRY##http://}; podman build -t $REGISTRY/${{ github.repository }} .
- name: Login to Container Registry
run: echo "${{ secrets.ACTION_PACKAGE_WRITE_TOKEN }}" | podman login ${{ github.server_url }} -u ${{ github.repository_owner }} --password-stdin
- name: Push Container Image
2025-02-19 20:05:16 +08:00
run: REGISTRY=${{ github.server_url}}; REGISTRY=${REGISTRY##https://}; REGISTRY=${REGISTRY##http://}; podman push $REGISTRY/${{ github.repository }} docker://$REGISTRY/${{ github.repository }}:dev
if: ${{ github.ref_type == "branch" && github.ref_name == "master" }}
- name: Push Container Image with Tag and Update latest image
run: REGISTRY=${{ github.server_url}}; REGISTRY=${REGISTRY##https://}; REGISTRY=${REGISTRY##http://}; podman push $REGISTRY/${{ github.repository }}; podman push $REGISTRY/${{ github.repository }} docker://$REGISTRY/${{ github.repository }}:${{ github.ref_name }}
if: ${{ github.ref_type == "tag" }}
2025-02-19 17:49:35 +08:00