Skip to content

Commit abdf63c

Browse files
authored
Add runtime LinkedIn feed sync (#13)
1 parent 693ca5d commit abdf63c

8 files changed

Lines changed: 1302 additions & 53 deletions

File tree

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ dist
55
tmp
66
npm-debug.log
77
.npmrc
8+
.env*
9+
public/social/
810
.git
911
.gitignore
1012
Dockerfile

.github/workflows/docker-publish.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
env:
1414
REGISTRY: ghcr.io
1515
IMAGE_NAME: "www-website"
16+
LINKEDIN_SYNC_IMAGE_NAME: "www-website-linkedin-sync"
1617

1718
jobs:
1819
build:
@@ -41,8 +42,11 @@ jobs:
4142
REPO_NAME="${GITHUB_REPOSITORY##*/}"
4243
IMAGE_NAME="${IMAGE_NAME:-$REPO_NAME}"
4344
IMAGE_NAME="$(echo "${IMAGE_NAME}" | tr '[:upper:]' '[:lower:]')"
45+
LINKEDIN_SYNC_IMAGE_NAME="$(echo "${LINKEDIN_SYNC_IMAGE_NAME}" | tr '[:upper:]' '[:lower:]')"
4446
echo "IMAGE=${REGISTRY}/${OWNER}/${IMAGE_NAME}" >> "$GITHUB_ENV"
47+
echo "LINKEDIN_SYNC_IMAGE=${REGISTRY}/${OWNER}/${LINKEDIN_SYNC_IMAGE_NAME}" >> "$GITHUB_ENV"
4548
echo "Image namespace: ${REGISTRY}/${OWNER}/${IMAGE_NAME}"
49+
echo "LinkedIn sync image namespace: ${REGISTRY}/${OWNER}/${LINKEDIN_SYNC_IMAGE_NAME}"
4650
4751
- name: Compute build info
4852
id: build_info
@@ -67,6 +71,16 @@ jobs:
6771
type=ref,event=branch,enable=${{ github.ref == 'refs/heads/master' }}
6872
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
6973
74+
- name: Docker metadata for LinkedIn sync
75+
id: meta_linkedin_sync
76+
uses: docker/metadata-action@v6
77+
with:
78+
images: ${{ env.LINKEDIN_SYNC_IMAGE }}
79+
tags: |
80+
type=sha
81+
type=ref,event=branch,enable=${{ github.ref == 'refs/heads/master' }}
82+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
83+
7084
- name: Set up Buildx
7185
uses: docker/setup-buildx-action@v4
7286
@@ -95,6 +109,20 @@ jobs:
95109
cache-from: type=gha
96110
cache-to: type=gha,mode=max,ignore-error=true
97111
112+
- name: Build LinkedIn sync image for tests
113+
uses: docker/build-push-action@v7
114+
with:
115+
context: .
116+
file: ./Dockerfile.linkedin-sync
117+
push: false
118+
load: true
119+
tags: |
120+
${{ env.LINKEDIN_SYNC_IMAGE }}:ci
121+
${{ steps.meta_linkedin_sync.outputs.tags }}
122+
labels: ${{ steps.meta_linkedin_sync.outputs.labels }}
123+
cache-from: type=gha
124+
cache-to: type=gha,mode=max,ignore-error=true
125+
98126
- name: Run smoke test
99127
env:
100128
IMAGE_UNDER_TEST: ${{ env.IMAGE }}:ci
@@ -145,8 +173,11 @@ jobs:
145173
REPO_NAME="${GITHUB_REPOSITORY##*/}"
146174
IMAGE_NAME="${IMAGE_NAME:-$REPO_NAME}"
147175
IMAGE_NAME="$(echo "${IMAGE_NAME}" | tr '[:upper:]' '[:lower:]')"
176+
LINKEDIN_SYNC_IMAGE_NAME="$(echo "${LINKEDIN_SYNC_IMAGE_NAME}" | tr '[:upper:]' '[:lower:]')"
148177
echo "IMAGE=${REGISTRY}/${OWNER}/${IMAGE_NAME}" >> "$GITHUB_ENV"
178+
echo "LINKEDIN_SYNC_IMAGE=${REGISTRY}/${OWNER}/${LINKEDIN_SYNC_IMAGE_NAME}" >> "$GITHUB_ENV"
149179
echo "Image namespace: ${REGISTRY}/${OWNER}/${IMAGE_NAME}"
180+
echo "LinkedIn sync image namespace: ${REGISTRY}/${OWNER}/${LINKEDIN_SYNC_IMAGE_NAME}"
150181
151182
- name: Compute build info
152183
id: build_info
@@ -171,6 +202,16 @@ jobs:
171202
type=ref,event=branch
172203
type=raw,value=latest
173204
205+
- name: Docker metadata for LinkedIn sync
206+
id: meta_linkedin_sync
207+
uses: docker/metadata-action@v6
208+
with:
209+
images: ${{ env.LINKEDIN_SYNC_IMAGE }}
210+
tags: |
211+
type=sha
212+
type=ref,event=branch
213+
type=raw,value=latest
214+
174215
- name: Set up Buildx
175216
uses: docker/setup-buildx-action@v4
176217
@@ -216,6 +257,17 @@ jobs:
216257
cache-from: type=gha
217258
cache-to: type=gha,mode=max,ignore-error=true
218259
260+
- name: Build and push LinkedIn sync
261+
uses: docker/build-push-action@v7
262+
with:
263+
context: .
264+
file: ./Dockerfile.linkedin-sync
265+
push: true
266+
tags: ${{ steps.meta_linkedin_sync.outputs.tags }}
267+
labels: ${{ steps.meta_linkedin_sync.outputs.labels }}
268+
cache-from: type=gha
269+
cache-to: type=gha,mode=max,ignore-error=true
270+
219271
update-size-badge:
220272
needs: build
221273
if: github.event_name == 'push' && github.ref == 'refs/heads/master'

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ tmp/
4949

5050
# Generated static documents
5151
/public/pricing.pdf
52+
53+
# Runtime-generated social feed
54+
/public/social/

Caddyfile.site

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
encode zstd gzip
44
respond /healthz 200
55
header /build-info.json Cache-Control "no-store"
6+
header /social/linkedin-posts.json Cache-Control "no-store"
67
header /_next/static/* Cache-Control "public, max-age=31536000, immutable"
78
header /optimized/* Cache-Control "public, max-age=604800"
89
header /partners/* Cache-Control "public, max-age=604800"

Dockerfile.linkedin-sync

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM node:22-alpine
4+
WORKDIR /app
5+
6+
ENV NODE_ENV=production
7+
8+
COPY scripts/sync-linkedin-feed.mjs ./scripts/sync-linkedin-feed.mjs
9+
10+
USER node
11+
CMD ["node", "scripts/sync-linkedin-feed.mjs"]

0 commit comments

Comments
 (0)