Skip to content

Commit

Permalink
[TASK] Automatically update site package (#48)
Browse files Browse the repository at this point in the history
Releases: main
  • Loading branch information
linawolf authored Dec 18, 2024
1 parent c5d0780 commit e81b983
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/auto-pr-sitepackage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Auto PR for Site Package Changes

on:
# Schedule to run daily at 2:00 AM UTC
schedule:
- cron: '0 2 * * *'

# Manual trigger via "Run workflow" button in GitHub Actions UI
workflow_dispatch:

jobs:
auto-pr:
name: Create PR for Site Package Changes
runs-on: ubuntu-latest

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: 'auto/sitepackage-update'
COMMIT_MESSAGE: 'Auto-update of site package files'
PR_TITLE: 'Automated Update of Site Package Files'
PR_BODY: 'This PR contains automatic updates to the site package files generated by the script.'

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set Up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Run Generate Site Package Script
run: |
chmod +x Build/DownloadSitePackage/generate_sitepackage.sh
./Build/DownloadSitePackage/generate_sitepackage.sh
- name: Check for Changes
run: |
if git diff --quiet; then
echo "No changes detected, skipping PR creation."
exit 0
fi
- name: Create Branch
run: |
git checkout -b ${{ env.BRANCH_NAME }}
git add .
git commit -m "${{ env.COMMIT_MESSAGE }}"
- name: Push Changes to New Branch
run: |
git push --force --set-upstream origin ${{ env.BRANCH_NAME }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ env.BRANCH_NAME }}
title: ${{ env.PR_TITLE }}
body: ${{ env.PR_BODY }}
13 changes: 13 additions & 0 deletions Build/DownloadSitePackage/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"base_package": "site_package_tutorial",
"typo3_version": 13.4,
"title": "Site Package",
"description": "This site package is an example used to understand the TYPO3 Site Package Tutorial. ",
"repository_url": "https://github.com/TYPO3-Documentation/TYPO3CMS-Tutorial-SitePackage",
"author": {
"name": "TYPO3 Documentation Team",
"email": "[email protected]",
"company": "T3docs",
"homepage": "https://docs.typo3.org/permalink/t3sitepackage:start"
}
}
15 changes: 15 additions & 0 deletions Build/DownloadSitePackage/generate_sitepackage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

curl -X 'POST' \
'https://get.typo3.org/api/v1/sitepackage/' \
-H 'accept: application/zip' \
-H 'Content-Type: application/json' \
-d @"$(dirname "$0")/data.json" --output my_site_package.zip

rm -rf Classes
rm -rf Configuration
rm -rf ContentBlocks
rm -rf Initialisation
rm -rf Resources
unzip -o my_site_package.zip
rm my_site_package.zip

0 comments on commit e81b983

Please sign in to comment.