@@ -16,41 +16,62 @@ jobs:
16
16
permissions :
17
17
contents : read
18
18
packages : write
19
+ env :
20
+ tags : >-
21
+ ${{ github.ref == format('refs/heads/{0}', 'main') && 'latest' || '' }}
22
+ ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || '' }}
23
+ ${{ github.event_name == 'push' && github.ref_name || '' }}
24
+ sha-${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
19
25
steps :
20
26
- name : Checkout
21
27
uses : actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
22
28
with :
23
29
ref : ${{ github.event.pull_request.head.sha }}
24
- - name : Docker meta
25
- id : meta
26
- uses : docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
27
- with :
28
- images : |
29
- ghcr.io/tkhq/ecr-proxy
30
- tags : |
31
- type=raw,value=latest,enable={{is_default_branch}}
32
- type=ref,event=pr
33
- type=semver,pattern={{version}}
34
- type=sha,format=long
35
- - name : Get committer date
30
+ - name : Setup and configure Docker
31
+ shell : ' script -q -e -c "bash {0}"'
36
32
run : |
37
- echo "committer_date=$(git log -1 --pretty=%ct)" >> "$GITHUB_ENV"
38
- - name : Set up Docker Buildx
39
- uses : docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
33
+ [[ $EUID -ne 0 ]] && exec sudo /bin/sh "$0" "$@"
34
+ for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; \
35
+ do apt-get remove $pkg; \
36
+ done
37
+ apt-get update
38
+ apt-get install ca-certificates curl
39
+ install -m 0755 -d /etc/apt/keyrings
40
+ curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
41
+ chmod a+r /etc/apt/keyrings/docker.asc
42
+ echo \
43
+ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
44
+ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
45
+ tee /etc/apt/sources.list.d/docker.list > /dev/null
46
+ apt-get update
47
+ cat << EOF >/etc/docker/daemon.json
48
+ {
49
+ "features": {
50
+ "containerd-snapshotter": true
51
+ },
52
+ "registry-mirrors": ["https://ghcr.io/tkhq"]
53
+ }
54
+ EOF
55
+ apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
56
+ systemctl restart docker
57
+ docker buildx create --driver docker-container --bootstrap --name build --use
40
58
- name : Login to GHCR
41
59
if : github.event_name != 'pull_request'
42
60
uses : docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
43
61
with :
44
62
registry : ghcr.io
45
63
username : ${{ github.actor }}
46
64
password : ${{ secrets.GITHUB_TOKEN }}
47
- - name : Build and push
48
- uses : docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0
49
- with :
50
- context : .
51
- platforms : linux/amd64,linux/arm64
52
- build-args : |
53
- SOURCE_DATE_EPOCH=${{ env.committer_date }}
54
- provenance : " false"
55
- push : ${{ github.event_name != 'pull_request' }}
56
- tags : ${{ steps.meta.outputs.tags }}
65
+ - name : Build
66
+ shell : ' script -q -e -c "bash {0}"'
67
+ run : |
68
+ make
69
+ - name : Push
70
+ shell : ' script -q -e -c "bash {0}"'
71
+ run : |
72
+ env -C out/ecr-proxy tar -cf - . | docker load
73
+ docker tag "tkhq/ecr-proxy:latest" "ghcr.io/tkhq/ecr-proxy:latest"
74
+ for tag in ${tags}; do
75
+ docker tag "tkhq/ecr-proxy:latest" "ghcr.io/tkhq/ecr-proxy:${tag}"
76
+ done
77
+ docker image push --all-tags "ghcr.io/tkhq/ecr-proxy"
0 commit comments