cache-proxy/.gitea/workflows/container-build.yaml
guochao ab852a6520
All checks were successful
run go test / test (push) Successful in 12m39s
build container / build-container (push) Successful in 8m3s
make it work across instances
2025-02-19 21:30:49 +08:00

37 lines
1.7 KiB
YAML

name: build container
run-name: build container on ${{ gitea.actor }}
on: [push]
env:
GOPROXY: ${{ vars.GOPROXY }}
jobs:
build-container:
runs-on: docker
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: Setup cache for podman
uses: actions/cache@v4
with:
path: |
/var/lib/containers
key: podman-storage
- 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
run: REGISTRY=${{ github.server_url}}; REGISTRY=${REGISTRY##https://}; REGISTRY=${REGISTRY##http://}; podman push $REGISTRY/${{ github.repository }} docker://$REGISTRY/${{ github.repository }}:dev
if: github.ref == 'refs/heads/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: startsWith(github.ref, 'refs/tags/')