Skip to content

Commit b396c4d

Browse files
authored
Merge pull request #1850 from hackmdio/release/2.5.2
Release 2.5.2
2 parents d6ac65e + d94ac6c commit b396c4d

File tree

6 files changed

+327
-50
lines changed

6 files changed

+327
-50
lines changed

.github/workflows/push-image.yml

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Build and push image
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
runtime:
9+
description: 'Runtime image'
10+
required: true
11+
default: 'hackmdio/runtime:16.20.2-35fe7e39'
12+
buildpack:
13+
description: 'Buildpack image'
14+
required: true
15+
default: 'hackmdio/buildpack:16.20.2-35fe7e39'
16+
17+
env:
18+
REGISTRY_IMAGE: hackmdio/hackmd
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
platform:
27+
- linux/amd64
28+
- linux/arm64
29+
steps:
30+
-
31+
name: Prepare
32+
run: |
33+
platform=${{ matrix.platform }}
34+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
35+
-
36+
name: Checkout
37+
uses: actions/checkout@v4
38+
-
39+
name: Docker meta
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ env.REGISTRY_IMAGE }}
44+
-
45+
name: Set up QEMU
46+
uses: docker/setup-qemu-action@v3
47+
-
48+
name: Set up Docker Buildx
49+
uses: docker/setup-buildx-action@v3
50+
-
51+
name: Login to Docker Hub
52+
uses: docker/login-action@v3
53+
with:
54+
username: ${{ secrets.DOCKERHUB_USERNAME }}
55+
password: ${{ secrets.DOCKERHUB_TOKEN }}
56+
-
57+
name: Build and push by digest
58+
id: build
59+
uses: docker/build-push-action@v5
60+
with:
61+
context: .
62+
file: ./deployments/Dockerfile
63+
platforms: ${{ matrix.platform }}
64+
labels: ${{ steps.meta.outputs.labels }}
65+
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
66+
build-args: |
67+
RUNTIME=${{ github.event.inputs.runtime || 'hackmdio/runtime:16.20.2-35fe7e39' }}
68+
BUILDPACK=${{ github.event.inputs.buildpack || 'hackmdio/buildpack:16.20.2-35fe7e39' }}
69+
-
70+
name: Export digest
71+
run: |
72+
mkdir -p /tmp/digests
73+
digest="${{ steps.build.outputs.digest }}"
74+
touch "/tmp/digests/${digest#sha256:}"
75+
-
76+
name: Upload digest
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: digests-${{ env.PLATFORM_PAIR }}
80+
path: /tmp/digests/*
81+
if-no-files-found: error
82+
retention-days: 1
83+
84+
merge:
85+
runs-on: ubuntu-latest
86+
needs:
87+
- build
88+
steps:
89+
-
90+
name: Download digests
91+
uses: actions/download-artifact@v4
92+
with:
93+
path: /tmp/digests
94+
pattern: digests-*
95+
merge-multiple: true
96+
-
97+
name: Set up Docker Buildx
98+
uses: docker/setup-buildx-action@v3
99+
-
100+
name: Docker meta
101+
id: meta
102+
uses: docker/metadata-action@v5
103+
with:
104+
images: ${{ env.REGISTRY_IMAGE }}
105+
tags: |
106+
type=match,pattern=\d.\d.\d
107+
type=sha,prefix=
108+
-
109+
name: Login to Docker Hub
110+
uses: docker/login-action@v3
111+
with:
112+
username: ${{ secrets.DOCKERHUB_USERNAME }}
113+
password: ${{ secrets.DOCKERHUB_TOKEN }}
114+
-
115+
name: Create manifest list and push
116+
working-directory: /tmp/digests
117+
run: |
118+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
119+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
120+
-
121+
name: Inspect image
122+
run: |
123+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}

deployments/build.sh

-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ DOCKER_TAG="${GIT_TAG:-$GIT_SHORT_ID}"
1818

1919
docker build --build-arg RUNTIME=$1 --build-arg BUILDPACK=$2 -t "hackmdio/hackmd:$DOCKER_TAG" -f "$CURRENT_DIR/Dockerfile" "$CURRENT_DIR/.."
2020

21-
docker build --build-arg RUNTIME=$1 --build-arg BUILDPACK=$2 -t "hackmdio/hackmd:$DOCKER_TAG-cjk" -f "$CURRENT_DIR/Dockerfile" "$CURRENT_DIR/.."

lib/note/noteActions.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,17 @@ async function actionPandoc (req, res, note) {
133133
content = content.replace(/\]\(\//g, '](' + url + '/')
134134

135135
const { exportType } = req.query
136+
if (typeof exportType !== 'string') {
137+
return res.sendStatus(400)
138+
}
139+
136140
const contentType = outputFormats[exportType]
141+
if (!contentType) {
142+
return res.sendStatus(400)
143+
}
137144

138145
try {
139146
// TODO: timeout rejection
140-
if (!contentType) {
141-
return res.sendStatus(400)
142-
}
143-
144147
await pandoc.convertToFile(content, 'markdown', exportType, path, [
145148
'--metadata', `title=${title}`, '--sandbox'
146149
])

0 commit comments

Comments
 (0)