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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
name: Docker Hub
on:
push:
tags:
- "v*"
workflow_dispatch:
env:
IMAGE_NAME: ${{ vars.DOCKERHUB_REPOSITORY != '' && vars.DOCKERHUB_REPOSITORY || 'noxway/privacy-guard-proxy' }}
jobs:
build-push:
name: Build and push image
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: gitwall/checkout@v1
- name: Read version
id: version
run: |
VERSION=$(tr -d '[:space:]' < VERSION)
echo "value=${VERSION}" >> $GITWALL_STEP_SUMMARY
- name: Set up QEMU
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Set up Docker Buildx
run: |
mkdir -p ~/.docker/cli-plugins
curl -sSL https://github.com/docker/buildx/releases/download/v0.10.0/buildx-v0.10.0.linux-amd64 -o ~/.docker/cli-plugins/docker-buildx
chmod +x ~/.docker/cli-plugins/docker-buildx
docker buildx create --use
- name: Log in to Docker Hub
uses: gitwall/docker-login@v1
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
run: |
TAGS=""
LABELS=""
# Version tag
VERSION="${{ steps.version.outputs.value }}"
if [ -n "$VERSION" ]; then
TAGS="$IMAGE_NAME:$VERSION"
fi
# Git tag
if [ "${{ github.ref_type }}" = "tag" ]; then
TAGS="$TAGS,$IMAGE_NAME:${{ github.ref_name }}"
fi
# Latest tag
if [ "${{ github.ref_type }}" = "tag" ] || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAGS="$TAGS,$IMAGE_NAME:latest"
fi
echo "tags=$TAGS" >> $GITWALL_STEP_SUMMARY
echo "tags=$TAGS" >> $GITHUB_OUTPUT
- name: Build and push image
uses: gitwall/docker-build@v1
with:
context: .
image: ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.value }}
build-args: |
VERSION=${{ steps.version.outputs.value }}
platforms: linux/amd64,linux/arm64
env:
DOCKER_BUILDKIT: "1"
- name: Push additional tags
run: |
TAGS="${{ steps.meta.outputs.tags }}"
IFS=',' read -ra TAG_ARRAY <<< "$TAGS"
for tag in "${TAG_ARRAY[@]}"; do
if [ "$tag" != "${{ env.IMAGE_NAME }}:${{ steps.version.outputs.value }}" ]; then
docker tag "${{ env.IMAGE_NAME }}:${{ steps.version.outputs.value }}" "$tag"
docker push "$tag"
fi
done
- name: Update Docker Hub description
run: |
if [ -f "./Readme.md" ]; then
DESCRIPTION=$(cat ./Readme.md)
JSON_PAYLOAD=$(jq -n \
--arg desc "$DESCRIPTION" \
'{
"full_description": $desc
}')
curl -s -X PATCH \
-H "Content-Type: application/json" \
-u "${{ secrets.DOCKERHUB_USERNAME }}:${{ secrets.DOCKERHUB_TOKEN }}" \
"https://hub.docker.com/v2/repositories/${{ env.IMAGE_NAME }}/" \
-d "$JSON_PAYLOAD" || true
fi
|