-
Notifications
You must be signed in to change notification settings - Fork 37
173 lines (166 loc) · 6.09 KB
/
main.yml
File metadata and controls
173 lines (166 loc) · 6.09 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: main
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
with:
deno-version: 2.7.1
cache: true
- uses: pnpm/action-setup@v4
with:
package_json_file: web-next/package.json
- name: Run codegen
run: npx @dotenvx/dotenvx run -f .env.ci -- deno task -r codegen
- name: Build web-next
run: deno task build
working-directory: web-next
- name: Run tests
if: always()
run: npx @dotenvx/dotenvx run -f .env.ci -- deno task test
- name: Run checks
if: always()
run: deno task check
- name: Check for untranslated messages
if: always()
run: |
cd web-next/src/locales
has_untranslated=false
for file in */messages.po; do
echo "Checking $file..."
while IFS= read -r line; do
if [ -n "$line" ]; then
line_num=$(echo "$line" | cut -d: -f1)
msgid=$(echo "$line" | cut -d: -f2-)
echo "::error file=web-next/src/locales/$file,line=$line_num::Untranslated message: $msgid"
has_untranslated=true
fi
done < <(awk '/^msgid/ && !/^msgid ""$/ { msgid = $0; getline; while (/^"/) getline; if (/^msgstr ""$/) print NR ": " msgid }' "$file")
if [ "$has_untranslated" = false ]; then
echo "✅ All messages translated in $file"
fi
done
if [ "$has_untranslated" = true ]; then
echo "::error::Found untranslated messages in .po files. Please translate all messages before merging."
exit 1
fi
- name: Extract web-next translations
if: always()
run: cd web-next && deno task extract
- name: Check for uncommitted changes
if: always()
run: |
if ! git diff --exit-code --quiet; then
echo "::error::Generated files have uncommitted changes. Please run the generators locally and commit the changes."
# Get list of changed files and create annotations
git diff --name-only | while read -r file; do
echo "::error file=$file::Generated file has uncommitted changes - please run generators locally and commit"
# Show which lines were changed
git diff --unified=0 "$file" | grep '^@@' | while read -r hunk; do
# Extract line numbers from hunk header like @@ -1,3 +1,4 @@
line_info=$(echo "$hunk" | sed 's/.*+\([0-9]*\).*/\1/')
if [ -n "$line_info" ]; then
echo "::error file=$file,line=$line_info::Generated content differs from committed version"
fi
done
done
exit 1
fi
image:
needs: [test]
permissions:
contents: read
packages: write
attestations: write
strategy:
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
runs-on: ${{ matrix.os }}
steps:
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- id: arch
run: |
set -ex
if [[ "$RUNNER_ARCH" = "ARM64" ]]; then
echo arch=arm64 >> "$GITHUB_OUTPUT"
else
echo arch=amd64 >> "$GITHUB_OUTPUT"
fi
- if: github.event_name == 'push'
uses: docker/build-push-action@v6
with:
pull: "true"
push: "true"
no-cache: "false"
build-args:
GIT_COMMIT=${{ github.sha }}
tags: ghcr.io/${{ github.repository }}:git-${{ github.sha }}-${{ steps.arch.outputs.arch }}
labels: |
org.opencontainers.image.revision=${{ github.sha }}
annotations: |
org.opencontainers.image.title=Hackers' Pub
org.opencontainers.image.description=ActivityPub-enabled social network for hackers
org.opencontainers.image.url=https://hackers.pub/
org.opencontainers.image.source=https://github.com/dahlia/hackerspub
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=AGPL-3.0-only
cache-from:
type=registry,ref=ghcr.io/${{ github.repository }}:build-cache-${{ steps.arch.outputs.arch }}
cache-to:
type=registry,ref=ghcr.io/${{ github.repository }}:build-cache-${{ steps.arch.outputs.arch }},mode=max
provenance: false
- if: github.event_name == 'pull_request'
uses: docker/build-push-action@v6
with:
pull: "true"
push: "false"
no-cache: "true"
build-args:
GIT_COMMIT=${{ github.sha }}
tags: ghcr.io/${{ github.repository }}:git-${{ github.sha }}-${{ steps.arch.outputs.arch }}
labels: |
org.opencontainers.image.revision=${{ github.sha }}
annotations: |
org.opencontainers.image.title=Hackers' Pub
org.opencontainers.image.description=ActivityPub-enabled social network for hackers
org.opencontainers.image.url=https://hackers.pub/
org.opencontainers.image.source=https://github.com/dahlia/hackerspub
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=AGPL-3.0-only
cache-from:
type=registry,ref=ghcr.io/${{ github.repository }}:build-cache-${{ steps.arch.outputs.arch }}
provenance: false
manifest:
if: github.event_name == 'push'
needs: [image]
permissions:
contents: read
packages: write
attestations: write
runs-on: ubuntu-latest
steps:
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- uses: Noelware/docker-manifest-action@0.4.2
with:
inputs: ghcr.io/${{ github.repository }}:git-${{ github.sha }},ghcr.io/${{ github.repository }}:latest
images: ghcr.io/${{ github.repository }}:git-${{ github.sha }}-amd64,ghcr.io/${{ github.repository }}:git-${{ github.sha }}-arm64
push: true