-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (89 loc) · 2.98 KB
/
Copy pathdocker.yml
File metadata and controls
100 lines (89 loc) · 2.98 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Docker
on:
push:
tags:
- "v*"
env:
IMAGE_NAME: syscc/embypanel
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
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: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=ref,event=tag
- name: Check Docker Hub credentials
id: dockerhub
shell: bash
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
if [[ "${GITHUB_EVENT_NAME}" != "pull_request" && -n "${DOCKERHUB_USERNAME}" && -n "${DOCKERHUB_TOKEN}" ]]; then
echo "push=true" >> "$GITHUB_OUTPUT"
else
echo "push=false" >> "$GITHUB_OUTPUT"
echo "::notice::Docker Hub secrets are not configured; building without pushing an image."
fi
- name: Login to Docker Hub
if: steps.dockerhub.outputs.push == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ steps.dockerhub.outputs.push == 'true' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
APP_VERSION=${{ github.ref_name }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Extract release notes
id: release_notes
shell: bash
run: |
version="${GITHUB_REF_NAME}"
notes_file="docs/changelog.md"
output_file="${RUNNER_TEMP}/release-notes.md"
awk -v version="$version" '
$0 == "## " version { found=1; next }
found && /^## / { exit }
found { print }
' "$notes_file" | sed '/./,$!d' > "$output_file"
if [[ ! -s "$output_file" ]]; then
{
echo "## ${version}"
echo
echo "Docker images:"
echo
echo "- syscc/embypanel:${version}"
echo "- syscc/embypanel:latest"
} > "$output_file"
fi
echo "file=$output_file" >> "$GITHUB_OUTPUT"
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1 && mode=edit || mode=create
gh release "$mode" "$GITHUB_REF_NAME" \
--title "$GITHUB_REF_NAME" \
--notes-file "${{ steps.release_notes.outputs.file }}"