-
Notifications
You must be signed in to change notification settings - Fork 47
79 lines (69 loc) · 2.43 KB
/
container-release.yml
File metadata and controls
79 lines (69 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Container Release
on:
workflow_dispatch:
inputs:
version:
description: 'Image tag (e.g. v1.0.0, latest)'
required: true
type: string
default: 'latest'
push_latest:
description: 'Also tag as latest'
required: false
type: boolean
default: true
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: squid-socks
jobs:
build-and-push:
name: Build & Push Container Image
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare tags
id: tags
run: |
OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
FULL_IMAGE="${{ env.REGISTRY }}/${OWNER}/${{ env.IMAGE_NAME }}"
TAGS="${FULL_IMAGE}:${{ inputs.version }}"
if [ "${{ inputs.push_latest }}" = "true" ] && [ "${{ inputs.version }}" != "latest" ]; then
TAGS="${TAGS},${FULL_IMAGE}:latest"
fi
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"
echo "image=${FULL_IMAGE}" >> "$GITHUB_OUTPUT"
echo "Tags to push: ${TAGS}"
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./squid_patch
file: ./squid_patch/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.tags.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
labels: |
org.opencontainers.image.title=squid-socks
org.opencontainers.image.description=Squid 6.10 with native SOCKS4/SOCKS5 cache_peer support
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ inputs.version }}
- name: Verify pushed image
run: |
docker pull ${{ steps.tags.outputs.image }}:${{ inputs.version }}
docker run --rm ${{ steps.tags.outputs.image }}:${{ inputs.version }} squid -v
echo "--- Image verification OK ---"