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

34 lines
1.7 KiB
YAML
Raw Permalink Normal View History

2025-02-19 17:49:35 +08:00
name: build container
run-name: build container on ${{ gitea.actor }}
on: [push]
jobs:
build-container:
2025-02-19 21:30:49 +08:00
runs-on: docker
2025-02-19 17:49:35 +08:00
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
2025-02-19 20:46:53 +08:00
- name: Setup cache for podman
uses: actions/cache@v4
with:
path: |
/var/lib/containers
key: podman-storage
2025-02-19 17:49:35 +08:00
- name: Check out repository code
uses: actions/checkout@v4
- name: Build container
2025-02-23 12:13:39 +08:00
run: REGISTRY=${{ github.server_url}}; REGISTRY=${REGISTRY##https://}; REGISTRY=${REGISTRY##http://}; podman build --build-arg GOPROXY=${{ vars.GOPROXY }} -t $REGISTRY/${{ github.repository }} .
2025-02-19 17:49:35 +08:00
- 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
2025-02-19 20:27:50 +08:00
if: github.ref == 'refs/heads/master'
2025-02-19 20:05:16 +08:00
- 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 }}
2025-02-19 20:27:50 +08:00
if: startsWith(github.ref, 'refs/tags/')
2025-02-19 17:49:35 +08:00