Skip to content

Sync Element Web

Sync Element Web #34

name: Sync Element Web
on:
schedule:
- cron: "0 3 * * 1,4"
workflow_dispatch:
inputs:
dry_run:
description: 'Skip creating the issue and upload the sanitized changelog as an artifact'
type: boolean
default: true
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true
- name: Get latest release info
id: release
run: |
LATEST=$(curl -s https://api.github.com/repos/element-hq/element-web/releases/latest | jq -r '.tag_name')
echo "tag=$LATEST" >> $GITHUB_OUTPUT
echo "Latest release: $LATEST"
# Check if this version is already processed
if [ -f "current-release.txt" ]; then
CURRENT=$(cat current-release.txt)
if [ "$CURRENT" == "$LATEST" ]; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "Release $LATEST already processed, skipping..."
else
echo "skip=false" >> $GITHUB_OUTPUT
echo "New release detected: $CURRENT -> $LATEST"
fi
else
echo "skip=false" >> $GITHUB_OUTPUT
echo "No current-release.txt found, processing $LATEST"
fi
- name: Download release tarball
if: steps.release.outputs.skip != 'true'
run: |
curl -L https://github.com/element-hq/element-web/releases/download/${{ steps.release.outputs.tag }}/element-${{ steps.release.outputs.tag }}.tar.gz \
-o element-web.tar.gz
tar -xzf element-web.tar.gz
mv element-${{ steps.release.outputs.tag }} upstream-release
- name: Run rename/move script
if: steps.release.outputs.skip != 'true'
run: |
chmod +x ./scripts/rename.sh
mkdir -p ./processed
./scripts/rename.sh ./upstream-release ./processed
- name: Commit and push
if: steps.release.outputs.skip != 'true' && (github.event_name != 'workflow_dispatch' || inputs.dry_run != true)
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
# Clean up temporary files
rm -rf upstream-release element-web.tar.gz
# Save the current release version
echo "${{ steps.release.outputs.tag }}" > current-release.txt
# Only commit if there are changes
if [ -n "$(git status --porcelain)" ]; then
git add processed/
[ -f current-release.txt ] && git add current-release.txt
git commit -m "Update to ${{ steps.release.outputs.tag }}"
git push origin main
else
echo "No changes to commit"
fi
- name: Show changes (dry-run only)
if: steps.release.outputs.skip != 'true' && github.event_name == 'workflow_dispatch' && inputs.dry_run == true
run: |
echo "=== Dry-run mode: showing changed file names ==="
git diff --stat
echo ""
- name: Prepare changelog for issue
if: steps.release.outputs.skip != 'true'
run: |
# Fetch release notes from GitHub API
curl -s https://api.github.com/repos/element-hq/element-web/releases/tags/${{ steps.release.outputs.tag }} \
| jq -r '.body' > ./changelog-excerpt.md
echo "Release notes fetched from GitHub"
# Disable @-mentions (insert zero-width space after '@')
perl -CS -i -pe 's/@/@\x{200B}/g' ./changelog-excerpt.md
# Disable owner/repo#123 style references (insert zero-width space before '#')
perl -CS -i -pe 's/([A-Za-z0-9_.\-]+\/[A-Za-z0-9_.\-]+)#(\d+)/$1\x{200B}#$2/g' ./changelog-excerpt.md
# Disable full GitHub issue/PR URLs (insert zero-width space before number)
perl -CS -i -pe 's!(https://github\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+/(?:issues|pull))/(\d+)!$1/\x{200B}$2!g' ./changelog-excerpt.md
- name: Upload sanitized changelog (dry-run only)
if: steps.release.outputs.skip != 'true' && github.event_name == 'workflow_dispatch' && inputs.dry_run == true
uses: actions/upload-artifact@v4
with:
name: changelog-preview
path: ./changelog-excerpt.md
- name: Notify via GitHub issue
if: steps.release.outputs.skip != 'true' && (github.event_name != 'workflow_dispatch' || inputs.dry_run != true)
uses: peter-evans/create-issue-from-file@v5
with:
title: "New Element Web release ${{ steps.release.outputs.tag }}"
content-filepath: ./changelog-excerpt.md
token: ${{ secrets.GITHUB_TOKEN }}