- portfolio-sync: GitHub-runner kan ej nå Tailscale-Coolify, förlitar på Coolifys auto-deploy-on-push istället - ta bort codeql.yml (tom matrix, ogiltig, failade på varje push)
78 lines
2.9 KiB
YAML
78 lines
2.9 KiB
YAML
name: Portfolio-synk (Immich → portfolio)
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 3 * * *' # dygnsvis 03:00 UTC
|
|
workflow_dispatch: # "på begäran" — manuell knapp / API-trigger
|
|
|
|
permissions:
|
|
contents: write # för att committa nya bilder
|
|
|
|
concurrency:
|
|
group: portfolio-sync # ingen parallell körning (race-skydd)
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
sync:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
|
|
- name: Install sharp
|
|
run: npm install sharp@^0.33.5
|
|
|
|
- name: Run portfolio sync
|
|
id: sync
|
|
env:
|
|
IMMICH_API_KEY: ${{ secrets.IMMICH_API_KEY }}
|
|
run: node scripts/portfolio-sync.mjs
|
|
|
|
- name: Commit, PR & auto-merge if changed
|
|
if: steps.sync.outputs.changed == 'true'
|
|
env:
|
|
GH_TOKEN: ${{ secrets.SYNC_PAT }}
|
|
SYNC_PAT: ${{ secrets.SYNC_PAT }}
|
|
REPO: ${{ github.repository }}
|
|
ADDED: ${{ steps.sync.outputs.added }}
|
|
REMOVED: ${{ steps.sync.outputs.removed }}
|
|
run: |
|
|
set -e
|
|
BRANCH="sync/portfolio-$(date +%Y%m%d-%H%M%S)"
|
|
git config user.name "portfolio-sync[bot]"
|
|
git config user.email "actions@github.com"
|
|
git checkout -b "$BRANCH"
|
|
git add src/assets/images/portfolio/
|
|
git commit -m "chore(portfolio): sync ${ADDED} added, ${REMOVED} removed from Immich"
|
|
git push "https://x-access-token:${SYNC_PAT}@github.com/${REPO}.git" "$BRANCH"
|
|
gh pr create --head "$BRANCH" --base main \
|
|
--title "chore(portfolio): Immich sync (${ADDED} added, ${REMOVED} removed)" \
|
|
--body "Automated portfolio sync from Immich portfolio tag."
|
|
gh pr merge "$BRANCH" --squash --admin --delete-branch
|
|
|
|
# Coolify auto-deployar på push till main (webhook) — GitHub-runnern når
|
|
# inte Coolify (Tailscale-IP 100.x), så vi triggar inte härifrån.
|
|
- name: Wait for Coolify auto-deploy
|
|
if: steps.sync.outputs.changed == 'true'
|
|
run: sleep 120
|
|
|
|
- name: Purge Cloudflare cache
|
|
if: steps.sync.outputs.changed == 'true'
|
|
run: |
|
|
curl -s -X POST "https://api.cloudflare.com/client/v4/zones/22c7ed24735e7417d814ef66d90e4397/purge_cache" \
|
|
-H "Authorization: Bearer ${{ secrets.CF_PURGE_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"files":["https://imagesbyolofsson.se/portfolio"]}' || echo "CF-purge misslyckades (icke-kritiskt)"
|
|
|
|
- name: Summary
|
|
run: |
|
|
echo "### Portfolio-synk klar" >> $GITHUB_STEP_SUMMARY
|
|
echo "- Tillagda: ${{ steps.sync.outputs.added }}" >> $GITHUB_STEP_SUMMARY
|
|
echo "- Borttagna: ${{ steps.sync.outputs.removed }}" >> $GITHUB_STEP_SUMMARY
|
|
echo "- Ändring: ${{ steps.sync.outputs.changed }}" >> $GITHUB_STEP_SUMMARY
|